• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sublime.run_command函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sublime.run_command函数的典型用法代码示例。如果您正苦于以下问题:Python run_command函数的具体用法?Python run_command怎么用?Python run_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了run_command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
开发者ID:alexheyd,项目名称:sublime3-gitopenchangedfiles,代码行数:26,代码来源:GitOpenChangedFiles.py


示例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")
开发者ID:Pythoner-xu,项目名称:LuaSoar,代码行数:7,代码来源:LuaSoar.py


示例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")
开发者ID:artpi,项目名称:sublime3-gitopenchangedfiles,代码行数:34,代码来源:GitOpenChangedFiles.py


示例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)
开发者ID:facelessuser,项目名称:QuickCal,代码行数:35,代码来源:support.py


示例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 )
开发者ID:alex18881,项目名称:JsonL18nResourcesEditor,代码行数:27,代码来源:JsonL18nResourcesEditor.py


示例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)
开发者ID:toonnevelsteen,项目名称:sublime_settings,代码行数:34,代码来源:Package+Syncing.py


示例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")
开发者ID:LaTeXing,项目名称:LaTeXing,代码行数:25,代码来源:cache.py


示例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)
开发者ID:LaTeXing,项目名称:LaTeXing,代码行数:35,代码来源:cache.py


示例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)
开发者ID:chkb123456,项目名称:Deviot,代码行数:28,代码来源:pio_install.py


示例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)
开发者ID:DamnWidget,项目名称:UnitTesting,代码行数:7,代码来源:test.py


示例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)
开发者ID:adammendoza,项目名称:floobits-sublime,代码行数:31,代码来源:sublime_ui.py


示例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
         })
开发者ID:randy3k,项目名称:UnitTesting,代码行数:26,代码来源:scheduler.py


示例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}]})
开发者ID:jdcrensh,项目名称:ST_Plugins,代码行数:35,代码来源:BranchedWorkspace.py


示例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"]})
开发者ID:LaTeXing,项目名称:LaTeXing,代码行数:25,代码来源:compiler.py


示例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')
     )
开发者ID:KoenRijpstra,项目名称:SublimeServer,代码行数:7,代码来源:SublimeServer.py


示例16: launch_stata

def launch_stata():
	stata_fn = settings.get("stata_path")
	if not check_correct_executable(stata_fn):
		print('Stata path not found in settings')
		sublime.run_command('stata_update_executable_path')
		return

	#	stata_fn = settings.get("stata_path")
	#	if not check_correct_executable(stata_fn):
	#		sublime.error_message("Cannot run Stata; the path does not exist: {}".format(stata_fn))

	try:
		win32api.WinExec(stata_fn, win32con.SW_SHOWMINNOACTIVE)
		sublime.stata = win32com.client.Dispatch("stata.StataOLEApp")
	except:
		sublime.run_command('stata_register_automation')
		sublime.error_message("StataEditor: Stata Automation type library appears to be unregistered, see http://www.stata.com/automation/#install")

	# Stata takes a while to start and will silently discard commands sent until it finishes starting
	# Workaround: call a trivial command and see if it was executed (-local- in this case)
	seed = int(random.random()*1e6) # Any number
	for i in range(50):
		sublime.stata.DoCommand('local {} ok'.format(seed))
		sublime.stata.DoCommand('macro list')
		rc = sublime.stata.MacroValue('_{}'.format(seed))
		if rc=='ok':
			sublime.stata.DoCommand('local {}'.format(seed)) # Empty it
			sublime.stata.DoCommand('cap cls')
			print("Stata process started (waited {}ms)".format((1+i)/10))
			sublime.status_message("Stata opened!")
			break
		else:
			time.sleep(0.1)
	else:
		raise IOError('Stata process did not start before timeout')
开发者ID:ecodata,项目名称:StataEditor,代码行数:35,代码来源:StataEditorPlugin.py


示例17: openUrl

def openUrl(url):
	arduino_root = const.settings.get('arduino_root')
	arduino_root = getRealPath(arduino_root)
	reference_path = os.path.join(arduino_root, 'reference')
	reference_path = reference_path.replace(os.path.sep, '/')
	ref_file = 'file://%s/%s.html' % (reference_path, url)
	sublime.run_command('open_url', {'url': ref_file})
开发者ID:OpenDrain,项目名称:Stino,代码行数:7,代码来源:osfile.py


示例18: load

	def load(self, session):
		with open(session) as sess_file:
			data = json.load(sess_file)

		groups = data['groups']
		layout = data['layout']

		window = self.window
		open_files = [view.file_name() for view in window.views() if view.file_name()]

		# if the current window has open files, load the session in a new one
		if open_files:
			sublime.run_command('new_window')
			window = sublime.active_window()

		window.set_layout(layout)

		for group, files in groups.items():
			window.focus_group(int(group))

			for file in files:
				# if the string starts with buffer, it's an inline buffer and not a filename
				if file.startswith('buffer:'):
					window.new_file().run_command('insert', {'characters': file[7:]})
				else:
					window.open_file(file)

			for view in window.views():
				view.set_status('ss', path.basename(session))
开发者ID:DerekZiemba,项目名称:SimpleSession,代码行数:29,代码来源:SimpleSession.py


示例19: plugin_loaded

def plugin_loaded():
    global SUB_NOTIFY_READY

    # Create icon folder for systems that need a icon from path
    graphics = join(sublime.packages_path(), "SubNotify", "graphics")

    # Setup Notify
    notify.setup_notifications(
        "Sublime Text",
        join(graphics, "SublimeBubble.png"),
        join(graphics, "SublimeBubble.ico"),
        (
            get_settings().get(
                "terminal_notifier_path",
                "/Library/Ruby/Gems/2.0.0/gems/terminal-notifier-1.5.1/bin/terminal-notifier"
            ),
            "com.sublimetext.3"
        )
    )

    # Try to enable notification systems
    enable_notifications()

    # Annouce that subnotify is ready
    SUB_NOTIFY_READY = True
    sublime.run_command("sub_notify_is_ready")

    if get_settings().get("debug", False):
        sublime.set_timeout(lambda: sublime.run_command("sub_notify_test"), 3000)
开发者ID:xcorlett,项目名称:SubNotify,代码行数:29,代码来源:sub_notify.py


示例20: on_navigate

    def on_navigate(self, href):
        """Handle links."""

        if href.startswith('sub://Packages'):
            sublime.run_command('open_file', {"file": self.re_pkgs.sub('${packages}', href[6:])})
        else:
            webbrowser.open_new_tab(href)
开发者ID:facelessuser,项目名称:QuickCal,代码行数:7,代码来源:support.py



注:本文中的sublime.run_command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sublime.save_settings函数代码示例发布时间:2022-05-27
下一篇:
Python sublime.platform函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap