本文整理汇总了Python中sublime.platform函数的典型用法代码示例。如果您正苦于以下问题:Python platform函数的具体用法?Python platform怎么用?Python platform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了platform函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: open_file
def open_file(filepath):
if sublime.platform() == "osx":
subprocess.call(('open', filepath))
elif sublime.platform() == "windows":
os.startfile(filepath)
elif sublime.platform() == "linux":
subprocess.call(('xdg-open', filepath))
开发者ID:bordaigorl,项目名称:sublime-non-text-files,代码行数:7,代码来源:NonTextFiles.py
示例2: run
def run(self, edit, paste = True):
color = self.get_selected(edit) # in 'RRGGBB' format or None
binpath = os.path.join(sublime.packages_path(), usrbin, binname)
if sublime.platform() == 'windows':
color = self.pick_win(binpath, color)
else:
args = [binpath]
if color:
if sublime.platform() == 'osx':
args.append('-startColor')
args.append(color)
else:
args.append('#' + color)
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
color = proc.communicate()[0].strip()
if color:
if sublime.platform() != 'windows' or sublime_version == 2:
color = color.decode('utf-8')
color = '#' + color
if paste:
self.put_selected(edit, color)
开发者ID:Beatt,项目名称:ColorPicker,代码行数:28,代码来源:sublimecp.py
示例3: get_sublime_path
def get_sublime_path():
if sublime.platform() == 'osx':
return '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl'
elif sublime.platform() == 'linux':
return open('/proc/self/cmdline').read().split(chr(0))[0]
else:
return sys.executable
开发者ID:ertjaet,项目名称:SublimePro,代码行数:7,代码来源:SublimePro.py
示例4: create_environment
def create_environment():
"""Return a dict with os.environ augmented with a better PATH.
Platforms paths are added to PATH by getting the "paths" user settings
for the current platform.
"""
from . import persist
env = {}
env.update(os.environ)
paths = persist.settings.get('paths', {})
if sublime.platform() in paths:
paths = [os.path.abspath(os.path.expanduser(path))
for path in convert_type(paths[sublime.platform()], [])]
else:
paths = []
if paths:
env['PATH'] = os.pathsep.join(paths) + os.pathsep + env['PATH']
if logger.isEnabledFor(logging.INFO) and env['PATH']:
debug_print_env(env['PATH'])
return env
开发者ID:mandx,项目名称:SublimeLinter,代码行数:26,代码来源:util.py
示例5: plugin_loaded
def plugin_loaded():
if sublime.platform() == "windows":
settings_file = "CustomPATH (Windows).sublime-settings"
elif sublime.platform() == "osx":
settings_file = "CustomPATH (OSX).sublime-settings"
else:
settings_file = "CustomPATH (Linux).sublime-settings"
settings = sublime.load_settings(settings_file)
append_to_path = settings.get("append_to_path")
if append_to_path is None:
print("CustomPATH: no platform specific PATH settings found! Check readme!")
return
if settings.get("enabled", True):
if settings.get("override", False):
os.environ["PATH"] = os.pathsep.join(append_to_path)
else:
for path in append_to_path:
if path not in os.environ["PATH"]:
new_path = "{}{}".format(path, os.pathsep) + os.environ["PATH"]
os.environ["PATH"] = new_path
print("CustomPATH: new PATH:", os.environ["PATH"])
开发者ID:otonvm,项目名称:CustomPATH,代码行数:29,代码来源:CustomPATH.py
示例6: 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
开发者ID:Nielingluo,项目名称:Sublime-Text-2,代码行数:31,代码来源:package_cleanup.py
示例7: run_single_output
def run_single_output(self):
p = self.view.window().folders()[0]
if sublime.platform() == 'windows':
p += "\\build\\{}.exe".format(os.path.basename(p))
else:
p += "/build/{}.out".format(os.path.basename(p))
self.sharex = self.get_bat_ex()
command = self.get_shell_command()
command.append(self.sharex)
command.append(p)
process = 0
try:
if sublime.platform() == 'window':
process = subprocess.Popen(
command,
shell=False,
universal_newlines=True,
creationflags=CREATE_NEW_CONSOLE
)
else:
# go to the build directory and run the command
curdir = os.curdir
os.chdir(os.path.dirname(p))
process = subprocess.Popen(command)
os.chdir(curdir)
except CalledProcessError as e:
print(e.output)
process.terminate()
开发者ID:AramRafeq,项目名称:CppBuilder,代码行数:34,代码来源:Builder.py
示例8: path_to_dartium
def path_to_dartium(self):
'''Returns the path to the `chrome` binary of the 'Dartium' Chrome
build.
May throw a ConfigError that the caller must prepare for.
'''
# Dartium will not always be available on the user's machine.
bin_name = 'chrome.exe'
if sublime.platform() == 'osx':
bin_name = 'Contents/MacOS/Chromium'
elif sublime.platform() == 'linux':
bin_name = 'chrome'
try:
path = self.setts.get('dart_dartium_path')
except (KeyError, TypeError) as e:
raise ConfigError('could not find path to Dartium')
try:
full_path = os.path.join(path, bin_name)
full_path = os.path.expandvars(os.path.expanduser(full_path))
if not os.path.exists(full_path):
raise ConfigError()
return full_path
except Exception as e:
_logger.error(e)
raise ConfigError('could not find Dartium')
开发者ID:lgunsch,项目名称:config,代码行数:27,代码来源:sdk.py
示例9: get_article_paths
def get_article_paths(window):
article_paths = []
# load INPUTDIR
inputdir = None
makefile_params = parse_makefile(window)
if makefile_params and "INPUTDIR_"+sublime.platform() in makefile_params:
inputdir = makefile_params["INPUTDIR_"+sublime.platform()]
elif makefile_params and "INPUTDIR" in makefile_params:
inputdir = makefile_params["INPUTDIR"]
else:
return []
# get paths of all articles in INPUTDIR
inputdir_structure = os.walk(inputdir)
if inputdir_structure:
for (dirpath, dirnames, filenames) in inputdir_structure:
for filename in filenames:
article_path = os.path.join(dirpath, filename)
if re.search(default_filter, article_path):
article_paths.append(article_path)
else:
return []
return article_paths
开发者ID:Drey,项目名称:sublime-pelican,代码行数:25,代码来源:Pelican.py
示例10: get_base_dir
def get_base_dir(only_base):
platform = sublime.platform().title()
if (platform == "Osx"):
platform = "OSX"
settings = sublime.load_settings('AutoBackups ('+platform+').sublime-settings')
# Configured setting
backup_dir = settings.get('backup_dir')
now_date = str(datetime.datetime.now())
date = now_date[:10]
backup_per_day = settings.get('backup_per_day')
if (backup_per_day and not only_base):
backup_dir = backup_dir +'/'+ date
time = now_date[11:19].replace(':', '')
backup_per_time = settings.get('backup_per_time')
if (backup_per_day and backup_per_time == 'folder' and not only_base):
backup_dir = backup_dir +'/'+ time
if backup_dir != '':
return os.path.expanduser(backup_dir)
# Windows: <user folder>/My Documents/Sublime Text Backups
if (sublime.platform() == 'windows'):
backup_dir = 'D:/Sublime Text Backups'
if (backup_per_day and not only_base):
backup_dir = backup_dir +'/'+ date
return backup_dir
# Linux/OSX/other: ~/sublime_backups
backup_dir = '~/.sublime/backups'
if (backup_per_day and not only_base):
backup_dir = backup_dir +'/'+ date
return os.path.expanduser(backup_dir)
开发者ID:mateatslc,项目名称:sublimetext-autobackups,代码行数:34,代码来源:paths_helper.py
示例11: 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"
开发者ID:Kaizhi,项目名称:SublimeUpdater,代码行数:35,代码来源:SublimeUpdater.py
示例12: set_keymap
def set_keymap():
path = os.path.join(sublime.packages_path(), 'User', 'Default (' + PLATFORMS[sublime.platform()] + ').sublime-keymap')
con = ''
if os.path.isfile(path):
with open(path, 'r', encoding = 'utf-8') as fh:
con = str(fh.read())
if con.find('gohelper_godef') != -1:
return
if sublime.platform() == 'osx':
keymap = '{ "keys": ["super+.", "super+g"], "command": "gohelper_godef" }'
else:
keymap = '{ "keys": ["ctrl+.", "ctrl+g"], "command": "gohelper_godef" }'
start = con.find('[')
if start == -1:
keymap = '[\n ' + keymap + '\n]'
con = keymap
else:
keymap = '\n ' + keymap + ','
con = con[:start+1] + keymap + con[start+1:]
with open(path, 'w', encoding = 'utf-8') as fh:
fh.write(con)
开发者ID:AaronZhang2015,项目名称:GoHelper,代码行数:25,代码来源:go.py
示例13: run
def run(self, user=False):
# Add sublime-build file
items = [["LaTeXing/LaTeX.sublime-build", "User/LaTeX.sublime-build"]]
items += [["LaTeXing/LaTeX (TikZ).sublime-build", "User/LaTeX (TikZ).sublime-build"]]
# Add sublime-keymap files
items += [["LaTeXing/Default.sublime-keymap", "User/Default.sublime-keymap"]]
if sublime.platform() == "windows":
items += [["LaTeXing/Default (Windows).sublime-keymap", "User/Default (Windows).sublime-keymap"]]
elif sublime.platform() == "osx":
items += [["LaTeXing/Default (OSX).sublime-keymap", "User/Default (OSX).sublime-keymap"]]
elif sublime.platform() == "linux":
items += [["LaTeXing/Default (Linux).sublime-keymap", "User/Default (Linux).sublime-keymap"]]
# Add map files for bibsonomy, citeulike, mendeley, zotero
items += [["LaTeXing/latexing/api/bibsonomy.map", "User/LaTeXing/bibsonomy.map"]]
items += [["LaTeXing/latexing/api/citeulike.map", "User/LaTeXing/citeulike.map"]]
items += [["LaTeXing/latexing/api/mendeley.map", "User/LaTeXing/mendeley.map"]]
items += [["LaTeXing/latexing/api/zotero.map", "User/LaTeXing/zotero.map"]]
message = ["Open %s" % item[1 if user else 0] for item in items]
def on_done(i):
if i >= 0:
self.window.run_command("open_file", {"file": "${packages}/%s" % items[i][1 if user else 0]})
if sublime.ok_cancel_dialog("You are trying to access the extended settings, be sure that you know what you are doing. In case of a problem please reset the files and try it again before reporting any problem."):
self.window.show_quick_panel(message, on_done)
开发者ID:LaTeXing,项目名称:LaTeXing,代码行数:28,代码来源:settings.py
示例14: show_select_projects
def show_select_projects(self):
#
# Load projects list and show select popup
#
#Settings load:
settings = sublime.load_settings('ProjectsList.sublime-settings')
self.subl_path = get_sublime_path()
if not self.subl_path:
sublime.error_message("No Sublime path specified for current OS!")
raise Exception("No Sublime path specified for current OS!")
if settings.get('projects_'+sublime.platform()):
self.projects = settings.get('projects_'+sublime.platform())
else:
sublime.error_message("No projects definde, goto Manage Projects!")
raise Exception("No projects definde, goto Manage Projects!")
names = []
for i in self.projects:
names.append("%s" % (i["name"]))
self.window.show_quick_panel(names, self.selected, sublime.MONOSPACE_FONT)
开发者ID:d4rkr00t,项目名称:ProjectsList,代码行数:25,代码来源:ProjectsList.py
示例15: find_viewer
def find_viewer(name):
log.debug("%s" % name)
# Load settings
settings = tools.load_settings("LaTeXing", pdf_viewer_osx={}, pdf_viewer_windows={}, pdf_viewer_linux={})
if sublime.platform() == "windows":
# Check if key available
if name in settings["pdf_viewer_windows"]:
# Search all available locations
for item in settings["pdf_viewer_windows"][name]:
executable = command_executable([item], command_line_tool=False)
if executable:
return executable
elif sublime.platform() == "osx":
# Check if key available
if name in settings["pdf_viewer_osx"]:
# Search all available locations
for item in settings["pdf_viewer_osx"][name]:
if os.path.exists(item):
return item
elif sublime.platform() == "linux":
# Check if key available
if name in settings["pdf_viewer_linux"]:
# Search all available locations
for item in settings["pdf_viewer_linux"][name]:
executable = command_executable([item], command_line_tool=False)
if executable:
return executable
return None
开发者ID:LaTeXing,项目名称:LaTeXing,代码行数:33,代码来源:terminal.py
示例16: on_css_selector_entered
def on_css_selector_entered(self, selector):
# Create an output buffer
self.output_view = self.window.new_file()
self.output_view.set_name(selector + ' - Element Finder Results'
)
self.output_view.set_scratch(True)
self.output_view.set_syntax_file('Packages/Element Finder/Element Finder Results.tmLanguage')
self.output_view.settings().set('result_file_regex', "^([^ ].*) \([0-9]+ match(?:es)?\)$")
self.output_view.settings().set('result_line_regex', '^ +([0-9]+): ')
# Create a thread so that calling the command line app doesn't lock up the interface
sublime_settings = \
sublime.load_settings('Element Finder.sublime-settings')
settings = {'node_path': sublime_settings.get('node_path'),
'extension': sublime_settings.get('extension'),
'ignore': sublime_settings.get('ignore')}
# Let the user declare different Node paths for each OS, in case they sync the plugin across multiple computers
if sublime.platform() == 'osx'and sublime_settings.get('node_path_osx') is not None:
settings['node_path'] = sublime_settings.get('node_path_osx')
elif sublime.platform() == 'windows'and sublime_settings.get('node_path_windows') is not None:
settings['node_path'] = sublime_settings.get('node_path_windows')
elif sublime.platform() == 'linux'and sublime_settings.get('node_path_linux') is not None:
settings['node_path'] = sublime_settings.get('node_path_linux')
self.thread = CommandLineInterface(self.dirs, selector, settings)
self.thread.start()
self.handle_threading()
开发者ID:jlangston,项目名称:sublime-elfinder,代码行数:32,代码来源:Element+Finder.py
示例17: popen
def popen(cmd, **args):
log.debug("%s" % cmd)
# Set environment path
path_bak = set_envionpath()
try:
if sublime.platform() == "windows":
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo, env=os.environ, **args)
elif sublime.platform() == "osx" or sublime.platform() == "linux":
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=os.environ, **args)
except Exception as e:
log.error(e)
log.error(os.environ["PATH"])
# Reset environment path
reset_envionpath(path_bak)
# Reset environment path
reset_envionpath(path_bak)
return proc
开发者ID:LaTeXing,项目名称:LaTeXing,代码行数:25,代码来源:terminal.py
示例18: open_workspace_window2
def open_workspace_window2(cb):
if sublime.platform() == 'linux':
subl = open('/proc/self/cmdline').read().split(chr(0))[0]
elif sublime.platform() == 'osx':
floorc = utils.load_floorc_json()
subl = floorc.get('SUBLIME_EXECUTABLE')
if not subl:
settings = sublime.load_settings('Floobits.sublime-settings')
subl = settings.get('sublime_executable', '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl')
if not os.path.exists(subl):
return sublime.error_message('''Can't find your Sublime Text executable at %s.
Please add "sublime_executable": "/path/to/subl" to your ~/.floorc.json and restart Sublime Text''' % subl)
elif sublime.platform() == 'windows':
subl = sys.executable
else:
raise Exception('WHAT PLATFORM ARE WE ON?!?!?')
command = [subl]
if get_workspace_window() is None:
command.append('--new-window')
command.append('--add')
command.append(G.PROJECT_PATH)
msg.debug('command:', command)
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
poll_result = p.poll()
msg.debug('poll:', poll_result)
set_workspace_window(cb)
开发者ID:blake-newman,项目名称:floobits-sublime,代码行数:29,代码来源:window_commands.py
示例19: open_room_window
def open_room_window(cb):
if sublime.platform() == 'linux':
subl = open('/proc/self/cmdline').read().split(chr(0))[0]
elif sublime.platform() == 'osx':
# TODO: totally explodes if you install ST2 somewhere else
subl = settings.get('sublime_executable', '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl')
elif sublime.platform() == 'windows':
subl = sys.executable
else:
raise Exception('WHAT PLATFORM ARE WE ON?!?!?')
command = [subl]
if utils.get_room_window() is None:
command.append('--new-window')
command.append('--add')
command.append(G.PROJECT_PATH)
print('command:', command)
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
poll_result = p.poll()
print('poll:', poll_result)
def create_chat_view():
with open(os.path.join(G.COLAB_DIR, 'msgs.floobits.log'), 'w') as msgs_fd:
msgs_fd.write('')
msg.get_or_create_chat(cb)
utils.set_room_window(create_chat_view)
开发者ID:nilbus,项目名称:sublime-text-2-plugin,代码行数:26,代码来源:floobits.py
示例20: 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)
开发者ID:yanni4night,项目名称:sublime-custominsert,代码行数:35,代码来源:Custominsert.py
注:本文中的sublime.platform函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论