本文整理汇总了Python中sublime.set_timeout_async函数的典型用法代码示例。如果您正苦于以下问题:Python set_timeout_async函数的具体用法?Python set_timeout_async怎么用?Python set_timeout_async使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_timeout_async函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_load_async
def on_load_async( self, view ):
self.new_ColorScheme = None
window = view.window()
try:
windowVariables = window.extract_variables()
file = windowVariables[ "file" ]
filePath = windowVariables[ "file_path" ]
fileName = windowVariables[ "file_name" ]
except( AttributeError, KeyError ) as e :
return
settings = sublime.load_settings( "ConditionalColorSchemes.sublime-settings" )
preferred_ColorScheme_Set = settings.get( "preferred_ColorScheme_Set", "" )
include_FileName_In_FilePath = settings.get( "include_FileName_In_FilePath", "" )
fileName_ColorSchemes = settings.get( "fileName_ColorSchemes", [] )
filePath_ColorSchemes = settings.get( "filePath_ColorSchemes", [] )
if include_FileName_In_FilePath == True:
filePath = file
if preferred_ColorScheme_Set == "filePath_ColorSchemes":
self.get_Conditional_ColorScheme( fileName, fileName_ColorSchemes )
self.get_Conditional_ColorScheme( filePath, filePath_ColorSchemes )
elif preferred_ColorScheme_Set == "fileName_ColorSchemes":
self.get_Conditional_ColorScheme( filePath, filePath_ColorSchemes )
self.get_Conditional_ColorScheme( fileName, fileName_ColorSchemes )
if self.new_ColorScheme != None:
set_ColorScheme = lambda: view.settings().set( "color_scheme", self.new_ColorScheme )
sublime.set_timeout_async( set_ColorScheme )
示例2: on_selection
def on_selection(id):
if id == -1:
return
selection = menu_options[id]
if not selection.requires_action:
return
elif selection.menu_text == ADD_ALL_UNSTAGED_FILES:
self.git("add", "--update", ".")
scope_of_action = "all unstaged files"
elif selection.menu_text == ADD_ALL_FILES:
self.git("add", "--all")
scope_of_action = "all files"
elif selection.is_untracked:
self.git("add", "--", selection.filename)
scope_of_action = "`{}`".format(selection.filename)
else:
self.git("add", "--update", "--", selection.filename)
scope_of_action = "`{}`".format(selection.filename)
sublime.status_message("Successfully added `{}`.".format(
scope_of_action))
sublime.set_timeout_async(self.run_async, 0)
示例3: run
def run(self, edit):
interface = ui.get_interface(self.view.id())
non_cached_sections = (interface.get_view_regions("unstaged_files") +
interface.get_view_regions("untracked_files") +
interface.get_view_regions("merge_conflicts"))
non_cached_lines = util.view.get_lines_from_regions(
self.view,
self.view.sel(),
valid_ranges=non_cached_sections
)
non_cached_files = (
os.path.join(self.repo_path, line.strip())
for line in non_cached_lines
if line[:4] == " "
)
cached_sections = interface.get_view_regions("staged_files")
cached_lines = util.view.get_lines_from_regions(
self.view,
self.view.sel(),
valid_ranges=cached_sections
)
cached_files = (
os.path.join(self.repo_path, line.strip())
for line in cached_lines
if line[:4] == " "
)
sublime.set_timeout_async(
lambda: self.load_diff_windows(non_cached_files, cached_files), 0)
示例4: _with_open_file
def _with_open_file(self, filename, f):
"""Opens filename (relative to the plugin) in a new view, calls
f(view) to perform the tests.
"""
window = sublime.active_window()
path = os.path.join(plugin_path, filename)
view = window.open_file(path)
q = queue.Queue()
def async_test_view():
try:
# Wait for view to finish loading.
for n in range(500):
if view.is_loading():
time.sleep(0.01)
else:
break
else:
raise AssertionError('View never loaded.')
# Run the tests on this view.
f(view)
except Exception as e:
q.put(e)
else:
q.put(None)
try:
sublime.set_timeout_async(async_test_view, 0)
msg = q.get()
if msg:
raise msg
finally:
window.focus_view(view)
window.run_command('close_file')
示例5: launch_simulator
def launch_simulator(file_name):
QUICK_V3_ROOT = _find_environment_variable("QUICK_V3_ROOT")
if QUICK_V3_ROOT == None:
sublime.message_dialog("please set environment variable 'QUICK_V3_ROOT'")
return
WORKDIR = get_workdir(file_name)
if WORKDIR == None: return
BIN = ""
ARG = " -workdir %s -search-path %s/quick" % (WORKDIR, QUICK_V3_ROOT)
def _windows():
os.system("taskkill /F /IM simulator.exe")
return QUICK_V3_ROOT + "/tools/simulator/runtime/win32/simulator.exe"
def _mac():
os.system("ps -x|grep simulator|xargs kill -9")
# os.system("open /Applications/Xcode.app")
# QUICK_V3_ROOT + "/tools/simulator/runtime/mac/Simulator.app/Contents/MacOS/Simulator"
# "/Users/liangxie/Desktop/work/qgl/frameworks/cocos2d-x/tools/simulator/runtime/mac/Simulator.app/Contents/MacOS/Simulator"
return QUICK_V3_ROOT + "/tools/simulator/runtime/mac/Simulator.app/Contents/MacOS/Simulator"
# return QUICK_V3_ROOT + "../Desktop/work/qgl/runtime/mac/qgl Mac.app/Contents/MacOS/qgl Mac"
if _isWindows():
BIN = _windows()
if _is_mac():
BIN = _mac()
# if _isLinux(): _linux()
sublime.set_timeout_async(lambda:os.system(BIN + ARG), 0)
示例6: run
def run(self, filename=None, limit=6000, author=None, log_current_file=False):
self._pagination = 0
self._filename = filename
self._limit = limit
self._author = author
self._log_current_file = log_current_file
sublime.set_timeout_async(self.run_async)
示例7: start_stdout_watcher
def start_stdout_watcher(self):
sdk = SDK()
t = StdoutWatcher(self, sdk.path)
# Thread dies with the main thread.
t.daemon = True
# XXX: This is necessary. If we call t.start() directly, ST hangs.
sublime.set_timeout_async(t.start, 0)
示例8: start_command
def start_command(self, file_name, use_bundler=False):
is_legal, file_path, arguments = PathHelper.get_file(file_name, self.window)
if is_legal:
sublime.set_timeout_async(lambda file_path=file_path,bundle=use_bundler, args=arguments: self.start_command_async(file_path, bundle, *args), 0)
else:
sublime.message_dialog("File: " + file_path+" does not exists")
示例9: run
def run(self, edit, action=None, clr_tests=False, text=None, sync_out=True, crash_line=None, value=None):
v = self.view
scope_name = v.scope_name(v.sel()[0].begin()).rstrip()
file_syntax = scope_name.split()[0]
if action == 'insert':
v.insert(edit, v.sel()[0].begin(), text)
elif action == 'make_opd':
self.close_opds()
self.create_opd(clr_tests=clr_tests, sync_out=sync_out)
elif action == 'show_crash_line':
pt = v.text_point(crash_line - 1, 0)
v.erase_regions('crash_line')
v.add_regions('crash_line', [sublime.Region(pt + 0, pt + 0)], \
'variable.language.python', 'bookmark', \
sublime.DRAW_SOLID_UNDERLINE)
sublime.set_timeout_async(lambda pt=pt: v.show_at_center(pt), 39)
# print(pt)
elif action == 'get_var_value':
self.get_var_value()
elif action == 'show_var_value':
self.show_var_value(value)
elif action == 'toggle_using_debugger':
self.toggle_using_debugger()
elif action == 'sync_opdebugs':
w = v.window()
layout = w.get_layout()
def slow_hide(w=w, layout=layout):
if layout['cols'][1] < 1:
layout['cols'][1] += 0.001
w.set_layout(layout)
sublime.set_timeout(slow_hide, 1)
else:
layout['cols'][1] = 1
w.set_layout(layout)
print('stopped')
if len(layout['cols']) == 3:
if layout['cols'][1] != 1:
# hide opd panel
self.ruler_opd_panel = min(layout['cols'][1], 0.93)
layout['cols'][1] = 1
# <This Region May be uncomment>
#for x in w.views_in_group(1):
# x.run_command('test_manager', {'action': 'hide_text'})
# < / >
# slow_hide()
w.set_layout(layout)
else:
# show opd panel
layout['cols'][1] = self.ruler_opd_panel
need_x = self.ruler_opd_panel
# < This Region May be uncomment >
#for x in w.views_in_group(1):
# x.run_command('test_manager', {'action': 'show_text'})
# < / >
w.set_layout(layout)
示例10: init
def init(self) -> None:
"""Initialize this project anagonda
"""
if self.AVAILABLE is True:
self.install_tools()
def monitor():
start = time.time()
while not self.__tools_instaled() and time.time() - start <= 300: # noqa
time.sleep(0.5)
if time.time() - start >= 300:
sublime.message_dialog(
'Go utils not available for this project, look at the '
'log panel to fix any issue with your system, then '
'restart Sublime Text 3'
)
else:
self._projects[self._project_name]['anagonda'] = True
if os.name != 'nt':
sublime.set_timeout_async(
lambda: sublime.active_window().run_command(
'anaconda_go_fill_browse'), 0
)
sublime.set_timeout_async(lambda: monitor(), 0)
示例11: run
def run(self):
scriptPath = inspect.getframeinfo(inspect.currentframe()).filename
scriptDir = os.path.dirname(scriptPath)
os.chdir(scriptDir)
files = ",".join(sorted(BrowsersyncState.watchPaths))
index = sorted(BrowsersyncState.startFiles)[BrowsersyncState.startFileIndex]
server = os.path.dirname(index)
index = index.replace(server + "\\", "")
plat = sublime.platform()
killMethod = {
'osx': 'killall -KILL node-osx',
'linux': 'pkill -x node-linux',
'windows': 'taskkill /im node-windows.exe /f /t'
}.get(plat)
os.system(killMethod)
cmd = 'node-{0} browser_sync_launch.js "{1}" "{2}" "{3}"'
cmd = cmd.format(plat, server,files, index)
sublime.set_timeout_async(self.make_callback(cmd), 0)
示例12: run
def run(self, edit):
"""Command to index open tab RF file and create db index table.
Purpose of the command is create index, from the open tab.
Index should contain all the resource and library imports and
all global variables from variable tables and imported variable
files.
"""
log_file = get_setting(SettingObject.log_file)
python_binary = get_setting(SettingObject.python_binary)
table_dir = get_setting(SettingObject.table_dir)
makedirs(path.dirname(log_file), exist_ok=True)
open_tab = self.view.file_name()
if not open_tab:
message = 'Not able to index because no tabs are active'
sublime.status_message(message)
return
db_table_name = self.get_table_name(open_tab)
if db_table_name:
file_ = open(log_file, 'a')
sublime.set_timeout_async(self.run_single_index(
python_binary,
table_dir,
db_table_name,
file_
), 0)
file_.close()
message = update_current_view_index(self.view)
sublime.status_message(message)
else:
message = 'Not able to index file: {0}'.format(open_tab)
sublime.status_message(message)
示例13: oracle
def oracle(self, end_offset, begin_offset=None, mode="describe", callback=None):
""" Builds the oracle shell command and calls it, returning it's output as a string.
"""
pos = "#" + str(end_offset)
if begin_offset is not None:
pos = "#%i,#%i" %(begin_offset, end_offset)
env = get_setting("env")
# Build oracle cmd.
cmd = "export GOPATH=\"%(go_path)s\"; export PATH=%(path)s; oracle -pos=%(file_path)s:%(pos)s -format=%(output_format)s %(mode)s %(scope)s" % {
"go_path": env["GOPATH"],
"path": env["PATH"],
"file_path": self.view.file_name(),
"pos": pos,
"output_format": get_setting("oracle_format"),
"mode": mode,
# TODO if scpoe is not set, use main.go under pwd or sublime project path.
"scope": ' '.join(get_setting("oracle_scope"))}
if "GOROOT" in env:
gRoot = "export GOROOT=\"%s\"; " % env["GOROOT"]
cmd = gRoot + cmd
sublime.set_timeout_async(lambda: self.runInThread(cmd, callback), 0)
示例14: async_do
def async_do(f, progress_msg="Evernote operation", done_msg=None):
if not done_msg:
done_msg = progress_msg + ': ' + "done!"
status = {'done': False, 'i': 0}
def do_stuff(s):
try:
f()
except:
pass
finally:
s['done'] = True
def progress(s):
if s['done']:
sublime.status_message(done_msg)
else:
i = s['i']
bar = "... [%s=%s]" % (' '*i, ' '*(7-i))
sublime.status_message(progress_msg + bar)
s['i'] = (i + 1) % 8
sublime.set_timeout(lambda: progress(s), 100)
sublime.set_timeout(lambda: progress(status), 0)
sublime.set_timeout_async(lambda: do_stuff(status), 0)
示例15: apply_diffs_for_pts
def apply_diffs_for_pts(self, cursor_pts, reset):
in_cached_mode = self.view.settings().get("git_savvy.diff_view.in_cached_mode")
# Apply the diffs in reverse order - otherwise, line number will be off.
for pt in reversed(cursor_pts):
hunk_diff = self.get_hunk_diff(pt)
# The three argument combinations below result from the following
# three scenarios:
#
# 1) The user is in non-cached mode and wants to stage a hunk, so
# do NOT apply the patch in reverse, but do apply it only against
# the cached/indexed file (not the working tree).
# 2) The user is in non-cached mode and wants to undo a line/hunk, so
# DO apply the patch in reverse, and do apply it both against the
# index and the working tree.
# 3) The user is in cached mode and wants to undo a line hunk, so DO
# apply the patch in reverse, but only apply it against the cached/
# indexed file.
#
# NOTE: When in cached mode, no action will be taken when the user
# presses SUPER-BACKSPACE.
self.git(
"apply",
"-R" if (reset or in_cached_mode) else None,
"--cached" if (in_cached_mode or not reset) else None,
"-",
stdin=hunk_diff
)
sublime.set_timeout_async(lambda: self.view.run_command("gs_diff_refresh"))