本文整理汇总了Python中sublime.arch函数的典型用法代码示例。如果您正苦于以下问题:Python arch函数的具体用法?Python arch怎么用?Python arch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了arch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self, edit, encoding, file_name):
self.view.set_name("ConvertToUTF8 Instructions")
self.view.set_scratch(True)
self.view.settings().set("word_wrap", True)
msg = "Oops! The file {0} is detected as {1} which is not supported by your Sublime Text.\n\nPlease check whether it is in the list of Python's Standard Encodings (http://docs.python.org/library/codecs.html#standard-encodings) or not.\n\nIf yes, ".format(
file_name, encoding
)
branch = self.get_branch(sublime.platform(), sublime.arch())
if branch:
ver = "33" if ST3 else "26"
msg = (
msg
+ "please install Codecs{0} (https://github.com/seanliang/Codecs{0}/tree/{1}) and restart Sublime Text to make ConvertToUTF8 work properly. If it is still not working, ".format(
ver, branch
)
)
import platform
msg = (
msg
+ "please kindly send the following information to sunlxy#yahoo.com:\n====== Debug Information ======\nVersion: {0}-{1}\nPlatform: {2}\nPath: {3}\nEncoding: {4}\n".format(
sublime.version(), sublime.arch(), platform.platform(), sys.path, encoding
)
)
self.view.insert(edit, 0, msg)
self.view.set_read_only(True)
self.view.window().focus_view(self.view)
示例2: run
def run(self):
if int(self.getLatestVersion()) == int(sublime.version()):
print ("currently on latest version")
else:
print ("new version available")
if sublime.platform() == "windows":
#download the latest installer
s = sublime.load_settings("Preferences.sublime-settings") #get the install path from preferences
install_path = s.get("install_path", "")
f = urllib2.urlopen("http://www.sublimetext.com/2")
format = formatter.NullFormatter()
parser = LinksParser(format)
html = f.read()
parser.feed(html) #get the list of latest installer urls
parser.close()
urls = parser.get_links()
if sublime.arch() == "x32":
download_link = urls[1]
elif sublime.arch() == "x64":
download_link = urls[3]
download_link = quote(download_link, safe="%/:=&?~#+!$,;'@()*[]")
sublime.status_message('SublimeUpdater is downloading update')
thr = BackgroundDownloader(download_link, install_path, download_link) #start the download thread
threads = []
threads.append(thr)
thr.start()
elif sublime.platform() == "linux":
print "linux detected"
elif sublime.platform() == "osx":
print "mac detected"
示例3: get_cache
def get_cache():
import platform
import os
if cindex.conf == None:
try:
cindex.conf = cindex.Config()
cindex.arch = sublime.arch()
cindex.register_enumerations()
print(cindex.conf.library_file)
except OSError as err:
print(err)
library = cindex.conf.library_file
if os.system == 'Linux':
common.error_message(
"""It looks like '%s' couldn't be loaded. On Linux use your package manager to install clang-3.7.1\n\n \
or alternatively download a pre-built binary from http://www.llvm.org and put it in your ~/bin/\n\n \
Visit https://github.com/ensisoft/SublimeClang for more information.""" % (library))
else:
common.error_message(
"""It looks like '%s' couldn't be loaded.\n\n \
Download a pre-built binary from http://www.llvm.org and install it in your system.\n\n \
Note that the architecture needs to match your SublimeText 2 architecture.\n\n \
Visit https://github.com/ensisoft/SublimeClang for more information.""" % (library))
raise err
if tulib.cachelib == None:
libcache = ""
packages = sublime.packages_path()
package = os.path.join(packages, "SublimeClang")
arch = sublime.arch()
try:
libname = tulib.get_cache_library(arch)
libcache = os.path.join(package, libname)
tulib.init_cache_lib(libcache)
print("Loaded: '%s'" % (libcache))
except OSError as err:
print(err)
if os.system == 'Linux':
common.error_message(
"""It looks like '%s' couldn't be loaded. On Linux you have to compile it yourself.\n\n \
Go to into your ~/.config/sublime-text-2/Packages/SublimeClang and run make.\n\n \
Visit https://github.com/ensisoft/SublimeClang for more information.""" % (libcache))
else:
common.error_message(
"""It looks like '%s' couldn't be loaded.\n\n \
Visit https://github.com/ensisoft/SublimeClang for more information.""" % (libcache))
raise err
if cache.tuCache == None:
number_threads = 4
cache.tuCache = TUCache(number_threads)
return cache.tuCache
示例4: setup
def setup():
if int(sublime.version()) < 3000:
# Sublime Text 2 & Python 2.6
messagehook.setup(callback)
else:
# Sublime Text 3 & Python 3.3
globalhook.setup(sublime.arch() == 'x64')
示例5: plugin_loaded
def plugin_loaded():
if DEBUG:
UTC_TIME = datetime.utcnow()
PYTHON = sys.version_info[:3]
VERSION = sublime.version()
PLATFORM = sublime.platform()
ARCH = sublime.arch()
PACKAGE = sublime.packages_path()
INSTALL = sublime.installed_packages_path()
message = (
'Jekyll debugging mode enabled...\n'
'\tUTC Time: {time}\n'
'\tSystem Python: {python}\n'
'\tSystem Platform: {plat}\n'
'\tSystem Architecture: {arch}\n'
'\tSublime Version: {ver}\n'
'\tSublime Packages Path: {package}\n'
'\tSublime Installed Packages Path: {install}\n'
).format(time=UTC_TIME, python=PYTHON, plat=PLATFORM, arch=ARCH,
ver=VERSION, package=PACKAGE, install=INSTALL)
sublime.status_message('Jekyll: Debugging enabled...')
debug('Plugin successfully loaded.', prefix='\n\nJekyll', level='info')
debug(message, prefix='Jekyll', level='info')
示例6: run
def run(self, message):
v = OutputPanel('dart.config.check')
text = HEADING + '\n'
text += ('=' * 80) + '\n'
text += 'MESSAGE:\n'
text += message + '\n'
text += '\n'
text += 'CONFIGURATION:\n'
text += ('-' * 80) + '\n'
text += "editor version: {} ({})".format(sublime.version(),
sublime.channel())
text += '\n'
text += ('-' * 80) + '\n'
text += "os: {} ({})".format(sublime.platform(),
sublime.arch())
text += '\n'
text += ('-' * 80) + '\n'
setts = sublime.load_settings('Dart - Plugin Settings.sublime-settings')
text += "dart_sdk_path: {}".format(setts.get('dart_sdk_path'))
text += '\n'
text += '=' * 80
v.write(text)
v.show()
示例7: setup
def setup():
if int(sublime.version()) < 3000:
# Sublime Text 2 & Python 2.6
pass
else:
# Sublime Text 3 & Python 3.3
globalhook.setup(sublime.arch() == 'x64')
示例8: _PrintDebugInfo
def _PrintDebugInfo():
"""Prints debug info into the sublime console."""
if not is_debug():
return
message = (
'AutoPEP8:'
'\n\tsublime: version=%(subl_version)s, platform=%(subl_platform)s,'
' arch=%(subl_arch)s,'
' packages_path=%(subl_packages)s\n,'
' installed_packages_path=%(subl_installed_packages)s'
'\n\tplugin: version=%(plugin_version)s'
'\n\tconfig: %(config)s'
)
config_keys = (
'max-line-length', 'list-fixes', 'ignore', 'select', 'aggressive',
'indent-size', 'format_on_save', 'syntax_list',
'file_menu_search_depth', 'avoid_new_line_in_select_mode', 'debug',
)
config = {}
for key in config_keys:
config[key] = Settings(key, None)
message_values = {
'plugin_version': VERSION,
'subl_version': sublime.version(),
'subl_platform': sublime.platform(),
'subl_arch': sublime.arch(),
'subl_packages': sublime.packages_path(),
'subl_installed_packages': sublime.installed_packages_path(),
'config': config
}
get_logger().debug(message, message_values)
示例9: collect
def collect(self):
self.elements.clear()
db0 = DataBlock('Version and architecture')
db0.items.append(DataItem('name', 'Sublime Text'))
db0.items.append(DataItem('version', sublime.version()))
db0.items.append(DataItem('architecture', sublime.arch()))
db0.items.append(DataItem('channel', sublime.channel()))
db0.items.append(DataItem('platform', sublime.platform()))
view = sublime.active_window().active_view()
view_settings = view.settings()
db1 = DataBlock('View settings')
for setting_name in ('syntax', 'tab_size', 'translate_tabs_to_spaces'):
db1.items.append(DataItem(setting_name, view_settings.get(setting_name)))
db2 = DataBlock('View state')
db2.items.append(DataItem('is view dirty', view.is_dirty()))
db2.items.append(DataItem('is view readonly', view.is_read_only()))
db1.items.append(DataItem('encoding', view.encoding()))
db1.items.append(DataItem('em width', view.em_width()))
db1.items.append(DataItem('selection count', len(view.sel())))
db1.items.append(DataItem('has non empty selections', view.has_non_empty_selection_region()))
self.elements.append(db0)
# TODO: Split the rest up into methods.
self.collect_package_data()
self.elements.append(db1)
self.elements.append(db2)
self.collect_profiling_data()
示例10: generate_dependency_paths
def generate_dependency_paths(name):
"""
Accepts a dependency name and generates a dict containing the three standard
import paths that are valid for the current machine.
:param name:
A unicode string name of the dependency
:return:
A dict with the following keys:
- 'ver'
- 'plat'
- 'arch'
"""
packages_dir = os.path.join(st_dir, u'Packages')
dependency_dir = os.path.join(packages_dir, name)
ver = u'st%s' % st_version
plat = sublime.platform()
arch = sublime.arch()
return {
'all': os.path.join(dependency_dir, 'all'),
'ver': os.path.join(dependency_dir, ver),
'plat': os.path.join(dependency_dir, u'%s_%s' % (ver, plat)),
'arch': os.path.join(dependency_dir, u'%s_%s_%s' % (ver, plat, arch))
}
示例11: get_predefined_param
def get_predefined_param(self, match):
'''{%%}'''
key = match.group(1)
if key == 'filename':
return os.path.basename(self.view.file_name() or '')
elif key == 'filepath':
return self.view.file_name() or ''
elif key == 'dirname':
return os.path.dirname(self.view.file_name() or '')
elif key == 'platform':
return sublime.platform()
elif key == 'arch':
return sublime.arch()
elif key == 'encoding':
encoding = self.view.encoding()
return encoding if 'Undefined' != encoding else self.settings.get('default_encoding')
elif key == 'ip':
return get_local_ip()
elif key == 'user':
user = os.getlogin() if 'windows' != sublime.platform() else ''
if user:
return user
#windows?
user = os.popen('whoami').read()
p = re.compile('[\r\n]', re.M)
return re.sub(p, '', user)
elif key == 'ext':
return get_ext(self.view.file_name())
elif key == 'year':
t = datetime.datetime.today()
return t.strftime('%Y')
elif key == 'datetime':
t = datetime.datetime.today()
return t.strftime(self.get_action_param('datetime_format', '%Y-%m-%d %H:%M:%S'))
return match.group(1)
示例12: is_compatible
def is_compatible(self, metadata):
"""
Detects if a package is compatible with the current Sublime Text install
:param metadata:
A dict from a metadata file
:return:
If the package is compatible
"""
sublime_text = metadata.get("sublime_text")
platforms = metadata.get("platforms", [])
# This indicates the metadata is old, so we assume a match
if not sublime_text and not platforms:
return True
if not is_compatible_version(sublime_text):
return False
if not isinstance(platforms, list):
platforms = [platforms]
platform_selectors = [sublime.platform() + "-" + sublime.arch(), sublime.platform(), "*"]
for selector in platform_selectors:
if selector in platforms:
return True
return False
示例13: get_dict_arch_path
def get_dict_arch_path():
"""Return Dict_arch.zip path."""
arch = sublime.arch()
if arch == "x32":
return os.path.join(BASE_PATH, "Dict32.zip")
elif arch == "x64":
return os.path.join(BASE_PATH, "Dict64.zip")
示例14: get_support_info
def get_support_info():
pc_settings = sublime.load_settings('Package Control.sublime-settings')
is_installed_by_pc = str(PACKAGE_NAME in set(pc_settings.get('installed_packages', [])))
info = {}
info['channel'] = sublime.channel()
info['version'] = sublime.version()
info['platform'] = sublime.platform()
info['arch'] = sublime.arch()
info['package_name'] = PACKAGE_NAME
info['package_version'] = PACKAGE_VERSION
info['pc_install'] = is_installed_by_pc
try:
import mdpopups
info['mdpopups_version'] = format_version(mdpopups, 'version', call=True)
except Exception:
info['mdpopups_version'] = 'Version could not be acquired!'
try:
import markdown
info['markdown_version'] = format_version(markdown, 'version')
except Exception:
info['markdown_version'] = 'Version could not be acquired!'
try:
import jinja2
info['jinja_version'] = format_version(jinja2, '__version__')
except Exception:
info['jinja_version'] = 'Version could not be acquired!'
try:
import pygments
info['pygments_version'] = format_version(pygments, '__version__')
except Exception:
info['pygments_version'] = 'Version could not be acquired!'
return '''%(package_name)s:\n\n* version: %(package_version)s\n* installed via Package Control: %(pc_install)s\n\nSublime Text:\n\n* channel: %(channel)s\n* version: %(version)s\n* platform: %(platform)s\n* architecture: %(arch)s\n\nDependency versions:\n\n* mdpopups: %(mdpopups_version)s\n* markdown: %(markdown_version)s\n* pygments: %(pygments_version)s\n* jinja2: %(jinja_version)s''' % info
示例15: send_to_api
def send_to_api(self):
"""
Send archive file to API
"""
self.set_message("Sending archive...")
f = open(self.archive_filename, 'rb')
files = {
'package': f.read(),
'version': sublime.version()[:1],
'platform': sublime.platform(),
'arch': sublime.arch(),
'email': self.email,
'api_key': self.api_key,
}
# Send data and delete temporary file
try:
r = requests.post(
url=self.api_upload_url, files=files, timeout=50)
except requests.exceptions.ConnectionError as err:
self.set_timed_message(
"Error while sending archive: server not available, try later",
clear=True)
self.running = False
logger.error(
'Server (%s) not available, try later.\n'
'==========[EXCEPTION]==========\n'
'%s\n'
'===============================' % (
self.api_upload_url, err))
return
f.close()
os.unlink(self.archive_filename)
if r.status_code == 201:
self.set_timed_message("Successfully sent archive", clear=True)
logger.info('HTTP [%s] Successfully sent archive' % r.status_code)
elif r.status_code == 403:
self.set_timed_message(
"Error while sending archive: wrong credentials", clear=True)
logger.info('HTTP [%s] Bad credentials' % r.status_code)
elif r.status_code == 413:
self.set_timed_message(
"Error while sending archive: filesize too large (>20MB)", clear=True)
logger.error("HTTP [%s] %s" % (r.status_code, r.content))
else:
msg = "Unexpected error (HTTP STATUS: %s)" % r.status_code
try:
j = r.json()
for error in j.get('errors'):
msg += " - %s" % error
except:
pass
self.set_timed_message(msg, clear=True, time=10)
logger.error('HTTP [%s] %s' % (r.status_code, r.content))
self.post_send()