本文整理汇总了Python中sublime.run_command函数的典型用法代码示例。如果您正苦于以下问题:Python run_command函数的具体用法?Python run_command怎么用?Python run_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_command函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self, edit):
sublime.run_command('refresh_folder_list')
current_folder = sublime.active_window().folders()[0]
git_path = self.which('git')
if not git_path:
self.print_with_error("git not found in PATH")
return
pr = subprocess.Popen( git_path + " diff --name-only $(git symbolic-ref HEAD 2>/dev/null)" , cwd = current_folder, shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE )
(filenames, error) = pr.communicate()
if error:
self.print_with_error(error)
return
else:
filenames_split = bytes.decode(filenames).splitlines()
filename_pattern = re.compile("([^" + self.system_folder_seperator() + "]+$)")
sorted_filenames = sorted(filenames_split, key=lambda fn: filename_pattern.findall(fn))
for file_modified in sorted_filenames:
filename = current_folder + self.system_folder_seperator() + file_modified
if os.path.isfile(filename):
sublime.active_window().open_file(filename)
self.print_with_status("Git: Opened files modified in branch")
示例2: save_all_file
def save_all_file(self):
# window = sublime.active_window()
# views = window.views()
# for view in views:
# if view.file_name():
# view.save
sublime.run_command("save_all")
示例3: run
def run(self, edit):
sublime.run_command('refresh_folder_list')
current_folder = sublime.active_window().folders()[0]
if sublime.platform() == "windows":
git_name = 'git.exe'
else:
git_name = 'git'
git_path = self.which(git_name)
if not git_path:
self.print_with_error("git not found in PATH")
return
compare_branch_to = settings.get('compare_branch_to', 'origin/master')
pr = subprocess.Popen("git diff --name-only origin/master" , cwd = current_folder, shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE )
(filenames, error) = pr.communicate()
if error:
self.print_with_error('Could not run git command. Ensure you have git properly installed: ' + str(error))
return
else:
filenames_split = bytes.decode(filenames).splitlines()
filename_pattern = re.compile("([^" + self.system_folder_seperator() + "]+$)")
sorted_filenames = sorted(filenames_split, key=lambda fn: filename_pattern.findall(fn))
for file_modified in sorted_filenames:
filename = current_folder + self.system_folder_seperator() + file_modified
if os.path.isfile(filename):
sublime.active_window().open_file(filename)
self.print_with_status("Git: Opened files modified in branch")
示例4: run
def run(self, page):
"""Open page."""
try:
import mdpopups
import pymdownx
has_phantom_support = (mdpopups.version() >= (1, 10, 0)) and (int(sublime.version()) >= 3124)
fmatter = mdpopups.format_frontmatter(frontmatter) if pymdownx.version_info[:3] >= (4, 3, 0) else ''
except Exception:
fmatter = ''
has_phantom_support = False
if not has_phantom_support:
sublime.run_command('open_file', {"file": page})
else:
text = sublime.load_resource(page.replace('${packages}', 'Packages'))
view = self.window.new_file()
view.set_name('QuickCal - Quick Start')
view.settings().set('gutter', False)
view.settings().set('word_wrap', False)
if has_phantom_support:
mdpopups.add_phantom(
view,
'quickstart',
sublime.Region(0),
fmatter + text,
sublime.LAYOUT_INLINE,
css=CSS,
wrapper_class="quick-cal",
on_navigate=self.on_navigate
)
else:
view.run_command('insert', {"characters": text})
view.set_read_only(True)
view.set_scratch(True)
示例5: make_views
def make_views(self, files):
count = len(files)+1
sublime.run_command("new_window")
newwin = sublime.active_window()
newwin.run_command( 'toggle_side_bar' )
newwin.run_command( 'toggle_menu' )
newwin.run_command( 'toggle_minimap' )
cols = [ i/100 for i in range(0 , 101, round(100/count)) ]
colscount = len(cols)-1
cells = [ [indx, 0, indx+1, 1] for indx, cell in enumerate(cols) if indx < colscount ]
#print( str(count) + " " + json.JSONEncoder().encode(files)+ " " + json.JSONEncoder().encode(cols) + " " + json.JSONEncoder().encode(cells))
newwin.set_layout( { "cols": cols, "rows": [0.0, 1.0], "cells": cells } )
view = newwin.new_file( )
view.settings().set( "l18ion_keysview", True )
newwin.set_view_index( view, 0, 0 )
for indx,c in enumerate(files):
view = newwin.open_file( c )
newwin.set_view_index( view, indx+1, 0 )
self.make_view_content( newwin, files )
示例6: on_done
def on_done(path):
if not os.path.isdir(path):
os.makedirs(path)
if os.path.isdir(path):
if os.listdir(path):
if sublime.ok_cancel_dialog("The selected folder is not empty, would you like to continue and override your local settings?", "Continue"):
override = True
else:
self.window.show_input_panel("Sync Folder", path, on_done, None, None)
return
else:
override = False
# Adjust settings
s.set("sync", True)
s.set("sync_folder", path)
# Reset last-run file
file_path = os.path.join(sublime.packages_path(), "User", "Package Control.last-run")
if os.path.isfile(file_path):
os.remove(file_path)
# Reset last-run file
file_path = os.path.join(sublime.packages_path(), "User", "Package Syncing.last-run")
if os.path.isfile(file_path):
os.remove(file_path)
sublime.save_settings("Package Syncing.sublime-settings")
sublime.status_message("sync_folder successfully set to \"%s\"" % path)
#
sublime.run_command("pkg_sync", {"mode": ["pull", "push"], "override": override})
else:
sublime.error_message("Invalid Path %s" % path)
示例7: cache
def cache(mode=["bin.cache"] + CACHE_NAMES):
tools.LtxSettings().set("ltx_rebuild_cache", True)
if "bin.cache" in mode:
cache_bin()
if "pkg.cache" in mode:
cache_pkg()
if "doc.cache" in mode:
cache_doc()
if "bibsonomy.cache" in mode:
cache_bibsonomy()
if "citeulike.cache" in mode:
cache_citeulike()
if "mendeley.cache" in mode:
cache_mendeley()
if "zotero.cache" in mode:
cache_zotero()
if "tex.cache" in mode:
cache_tex()
if "bib.cache" in mode:
cache_bib()
tools.LtxSettings().set("ltx_rebuild_cache", False)
sublime.run_command("ltx_save_cache")
示例8: run
def run(self, cache=True, save=False, synchronise=False, fill_source=False):
cache_timeout = self.settings["cache"]["bibsonomy"] if "bibsonomy" in self.settings["cache"] else 0
if cache_timeout and not save:
cached_data = CACHE.get_cache_data("bibsonomy.cache")
else:
cached_data = {}
if cached_data and not synchronise and not CACHE.is_cache_outdated("bibsonomy.cache", cache_timeout):
self.data = cached_data
else:
if fill_source:
if not cache_timeout:
sublime.error_message("Bibsonomy.cache disabled! Please activate the cache to use this function.")
elif not tools.LtxSettings().get("ltx_offline", False) and sublime.ok_cancel_dialog("Bibsonomy.cache outdated, would you like to synchronise the data now? The items are available for the next call!", "Synchronise"):
sublime.run_command("ltx_sync_data", {"mode": "bibsonomy"})
else:
self.data = cached_data
else:
c = bibsonomy.Bibsonomy()
c.run()
self.status = c.status
if self.status in ["Error", "Waiting"]:
return
if self.status == "Ok":
# Build cite keys
for item in c.items:
item["cite_key"] = self.build_cite_key(item)
# Save items
self.data["cites"] = c.items
if cache and cache_timeout:
CACHE.set_cache_data("bibsonomy.cache", self.data, True)
示例9: check_python
def check_python(self):
"""Python requirement
Check if python 2 is installed
"""
self.version = None
cmd = [self.SYMLINK, '--version']
out = run_command(cmd)
if(out[0] == 0):
self.version = sub(r'\D', '', out[1])
if(int(self.version[0]) is 3):
self.check_sym_link()
# show error and link to download
if(out[0] > 0 or int(self.version[0]) is 3):
from ..libraries.I18n import I18n
_ = I18n().translate
go_to = sublime.ok_cancel_dialog(
_("deviot_need_python"), _("button_download_python"))
if(go_to):
sublime.run_command(
'open_url', {'url': 'https://www.python.org/downloads/'})
exit(0)
示例10: test_error
def test_error(self):
# Run unittesting for an non existing package
sublime.run_command("unit_testing", {"package": "_Error"})
with open(os.path.join(outputdir, "_Error"), 'r') as f:
txt = f.read()
m = re.search('^ERROR', txt, re.MULTILINE)
self.assertEqual(hasattr(m, "group"), True)
示例11: open_workspace_window3
def open_workspace_window3(abs_path, cb):
def finish(w):
w.set_project_data({'folders': [{'path': abs_path}]})
cb(w)
def get_empty_window():
for w in sublime.windows():
project_data = w.project_data()
try:
folders = project_data.get('folders', [])
if len(folders) == 0 or not folders[0].get('path'):
# no project data. co-opt this window
return w
except Exception as e:
print(str_e(e))
def wait_empty_window(i):
if i > 10:
print('Too many failures trying to find an empty window. Using active window.')
return finish(sublime.active_window())
w = get_empty_window()
if w:
return finish(w)
return utils.set_timeout(wait_empty_window, 50, i + 1)
w = get_workspace_window(abs_path) or get_empty_window()
if w:
return finish(w)
sublime.run_command('new_window')
wait_empty_window(0)
示例12: run
def run(self):
if self.syntax_test:
sublime.run_command("unit_testing_syntax", {
"package": self.package,
"output": self.output
})
elif self.syntax_compatibility:
sublime.run_command("unit_testing_syntax_compatibility", {
"package": self.package,
"output": self.output
})
elif self.color_scheme_test:
sublime.run_command("unit_testing_color_scheme", {
"package": self.package,
"output": self.output
})
elif self.coverage:
sublime.run_command("unit_testing_coverage", {
"package": self.package,
"output": self.output
})
else:
sublime.run_command("unit_testing", {
"package": self.package,
"output": self.output
})
示例13: load_branch
def load_branch(self, branch, root):
print("running def load_branch(self, " + str(branch) + ", " + str(root) + "):")
if not root:
print("load: off of git")
else:
print("load branch: " + branch)
path = root + "/.git/BranchedProjects.sublime"
obj = defaultdict(lambda: defaultdict(list))
if os.path.isfile(path):
with open(path, "rb") as f:
tmp = pickle.load(f)
for o in tmp:
obj[o] = tmp[o]
f.close()
for win in obj[branch]:
sublime.run_command("new_window")
new_win = sublime.active_window()
new_win.set_project_data({"folders": [{"path": root, "follow_symlinks": True}]})
for doc in obj[branch][win]:
if os.path.isfile(doc):
print("loading file " + doc)
new_win.open_file(doc)
no_win = True
for win in sublime.windows():
win_root = win.folders()
win_root = win_root[0] if win_root != [] else None
if win_root == root:
no_win = False
break
if no_win:
sublime.run_command("new_window")
new_win = sublime.active_window()
new_win.set_project_data({"folders": [{"path": root, "follow_symlinks": True}]})
示例14: update_remote_bibliography
def update_remote_bibliography(self):
settings = tools.load_settings("LaTeXing", bibname="Remote.bib", update_remote_bibliography=True)
# Fetch all available remote citations
remote_cites = {item.key: item for file_path, item in cite.find_remote_cites()}
if settings["update_remote_bibliography"] and remote_cites:
# Just search through the remote bib file, defined in the settings
bib_path = os.path.join(os.path.dirname(self.tex_file.root_file_path()), settings["bibname"])
bib_file = cache.BibFile(bib_path)
bib_file.run()
cites = []
for key in bib_file.cite_keys():
if key in remote_cites and remote_cites[key].string(plain=True) != bib_file.cite_source(key):
cites += [remote_cites[key]]
log.debug(key)
log.debug(bib_file.cite_source(key))
log.debug(remote_cites[key].string(plain=True))
# save cites in bib file and update cache
if cites and sublime.ok_cancel_dialog("%d Citation(s) in %s have been updated in your remote bibliography, update the item(s) prior the typeset?" % (len(cites), bib_file.file_name), "Update"):
bib_file.update_cites(cites)
bib_file.save()
sublime.run_command("ltx_save_cache", {"mode": ["bib.cache"]})
示例15: run
def run(self):
sublime.run_command('sublimeserver_stop')
sublime.set_timeout(lambda: sublime.run_command('sublimeserver_reload'), 0)
sublime.set_timeout(lambda:
sublime.run_command('sublimeserver_start'),
settings.get('interval')
)