当前位置: 首页>>代码示例>>Python>>正文


Python SBApplication.applicationWithBundleIdentifier_方法代码示例

本文整理汇总了Python中ScriptingBridge.SBApplication.applicationWithBundleIdentifier_方法的典型用法代码示例。如果您正苦于以下问题:Python SBApplication.applicationWithBundleIdentifier_方法的具体用法?Python SBApplication.applicationWithBundleIdentifier_怎么用?Python SBApplication.applicationWithBundleIdentifier_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScriptingBridge.SBApplication的用法示例。


在下文中一共展示了SBApplication.applicationWithBundleIdentifier_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_opened_files_adobe_cc

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
def _get_opened_files_adobe_cc(identifier: str) -> Iterator[Item]:
    """
    Retrieve documents path of opened files of the given bundle *identifier* (application).
    Where application is one of the Adobe Creative Suite:

        >>> get_opened_files_via_com("com.adobe.Photoshop")
        >>> get_opened_files_via_com("com.adobe.Illustrator")

    Complete specs of supported applications:
        - Illustrator: https://www.adobe.com/devnet/illustrator/scripting.html
        - Photoshop: https://www.adobe.com/devnet/photoshop/scripting.html
    """
    if not _is_running(identifier):
        return

    app = SBApplication.applicationWithBundleIdentifier_(identifier)

    if not app or not app.isRunning():
        return

    documents = app.documents()
    if not documents:
        return

    for doc in documents:
        file_path = doc.filePath()
        if not file_path:
            # The document is not yet saved and so has no path
            continue

        path = file_path.path()
        pid = compute_fake_pid_from_path(path)
        yield pid, Path(path)
开发者ID:nuxeo,项目名称:nuxeo-drive,代码行数:35,代码来源:files.py

示例2: GET

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
 def GET(self):
     
     iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
     track = iTunes.currentTrack()
     
     web.header('Content-Type','text/html; charset=utf-8') 
     return render.nowplaying(track=track, iTunes=iTunes, len=len)
开发者ID:vinc3m1,项目名称:nowplaying,代码行数:9,代码来源:code.py

示例3: start_server

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
def start_server():
    """Spawn server. Does not check if the server is already running.
    """
    if run_cmd == '':
        # Complex run command not given, build it from the information available
        if mswindows or darwin:
            cmd = []
        else:
            cmd = ['urxvt', '-fn', 'xft:Consolas-8', '-T', 'Slimv', '-e']
        cmd = cmd + [python_path, slimv_path, '-p', str(PORT), '-l', lisp_path, '-s']
    else:
        cmd = shlex.split(run_cmd)

    # Start server
    #TODO: put in try-block
    if mswindows:
        CREATE_NEW_CONSOLE = 16
        server = Popen( cmd, creationflags=CREATE_NEW_CONSOLE )
    elif darwin:
        from ScriptingBridge import SBApplication

        term = SBApplication.applicationWithBundleIdentifier_("com.apple.Terminal")
        term.doScript_in_(" ".join(cmd) + " ; exit", 0) 
    else:
        server = Popen( cmd )

    # Allow subprocess (server) to start
    time.sleep( 2.0 )
开发者ID:de-bug,项目名称:dotfiles,代码行数:30,代码来源:slimv.py

示例4: application_openFile_

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
 def application_openFile_(self, ns_app, path):
     terminal = SBApplication.applicationWithBundleIdentifier_("com.apple.Terminal")
     tab = terminal.doScript_in_("clear; %s; exit 0;" % (YAYBUC,), None)
     tab.setCustomTitle_(CUSTOM_WINDOW_TITLE )
     tab.setTitleDisplaysCustomTitle_(True)
     tab.setTitleDisplaysDeviceName_(False)
     tab.setTitleDisplaysFileName_(False)
     tab.setTitleDisplaysShellPath_(False)
     tab.setTitleDisplaysWindowSize_(False)
开发者ID:yaybu,项目名称:Yaybu.app,代码行数:11,代码来源:Application.py

示例5: _activate_window

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
def _activate_window():
    if sublime.platform() == 'osx':
        if SBApplication:
            subl_window = SBApplication.applicationWithBundleIdentifier_("com.sublimetext.2")
            subl_window.activate()
        else:
            os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Sublime Text" to true' ''')
    elif sublime.platform() == 'linux':
        subprocess.call("wmctrl -xa 'sublime_text.sublime-text-2'", shell=True)
开发者ID:trukanduk,项目名称:smate,代码行数:11,代码来源:smate.py

示例6: applicationOpenUntitledFile_

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
 def applicationOpenUntitledFile_(self, _):
     window, tab = find_best_yaybu_terminal()
     if window and tab:
         tab.setSelected_(True)
         window.setFrontmost_(True)
         term = SBApplication.applicationWithBundleIdentifier_("com.apple.Terminal")
         term.activate()
         return
     self.openYaybufile_(None)
开发者ID:yaybu,项目名称:Yaybu.app,代码行数:11,代码来源:Application.py

示例7: reload_safari

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
def reload_safari(keyword):
    safari = SBApplication.applicationWithBundleIdentifier_("com.apple.Safari")
    if not safari:
        print("Safari doesn't appear to be running!")
        return
    for window in safari.windows():
        for tab in window.tabs():
            if keyword in tab.URL():
                print("Reloading Safari: {}".format(tab.URL()))
                tab.setURL_(tab.URL())
开发者ID:davea,项目名称:watch,代码行数:12,代码来源:watch.py

示例8: reload_chrome

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
def reload_chrome(keyword):
    chrome = SBApplication.applicationWithBundleIdentifier_("com.google.Chrome")
    if not chrome:
        print("Chrome doesn't appear to be running!")
        return
    for window in chrome.windows():
        for tab in window.tabs():
            if keyword in tab.URL():
                print("Reloading Chrome: {}".format(tab.URL()))
                tab.reload()
开发者ID:davea,项目名称:watch,代码行数:12,代码来源:watch.py

示例9: on_done

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
    def on_done(self):
        # Create a secure temporary directory, both for privacy and to allow
        # multiple files with the same basename to be edited at once without
        # overwriting each other.
        try:
            self.temp_dir = tempfile.mkdtemp(prefix='rsub-')
        except OSError as e:
            sublime.error_message('Failed to create rsub temporary directory! Error: %s' % e)
            return
        self.temp_path = os.path.join(self.temp_dir,
                                      os.path.basename(self.env['display-name'].split(':')[-1]))
        try:
            temp_file = open(self.temp_path, "wb+")
            temp_file.write(self.file[:self.file_size])
            temp_file.flush()
            temp_file.close()
        except IOError as e:
            # Remove the file if it exists.
            if os.path.exists(self.temp_path):
                os.remove(self.temp_path)
            try:
                os.rmdir(self.temp_dir)
            except OSError:
                pass

            sublime.error_message('Failed to write to temp file! Error: %s' % str(e))

        # create new window if needed
        if len(sublime.windows()) == 0 or "new" in self.env:
            sublime.run_command("new_window")

        # Open it within sublime
        view = sublime.active_window().open_file(
            "{0}:{1}:0".format(
                self.temp_path, self.env['selection'] if 'selection' in self.env else 0),
            sublime.ENCODED_POSITION)

        # Add the file metadata to the view's settings
        # This is mostly useful to obtain the path of this file on the server
        view.settings().set('rsub', self.env)

        # Add the session to the global list
        SESSIONS[view.id()] = self

        # Bring sublime to front
        if(sublime.platform() == 'osx'):
            if(SBApplication):
                subl_window = SBApplication.applicationWithBundleIdentifier_("com.sublimetext.2")
                subl_window.activate()
            else:
                os.system("/usr/bin/osascript -e '%s'" %
                          'tell app "Finder" to set frontmost of process "Sublime Text" to true')
        elif(sublime.platform() == 'linux'):
            import subprocess
            subprocess.call("wmctrl -xa 'sublime_text.sublime-text-2'", shell=True)
开发者ID:aurora,项目名称:rsub,代码行数:57,代码来源:rsub.py

示例10: openTerminal_

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
 def openTerminal_(self, sender):
     """ Open a Terminal.app window running bpython,
         with the PlotDevice.app environment pre-loaded """
     TerminalApp = SBApplication.applicationWithBundleIdentifier_("com.apple.Terminal")
     scriptPythonPath = ":".join(sys.path)
     scriptBPythonExecutable = bundle_path(shared='bplotdevice')
     scriptBPythonSetup = bundle_path(rsrc='plotdevice-term.py')
     scriptCommand = '''cd %s && PYTHONPATH="%s" %s -i %s && exit''' % (
         bundle_path(), scriptPythonPath, scriptBPythonExecutable, scriptBPythonSetup)
     TerminalApp.activate()
     TerminalApp.doScript_in_(scriptCommand, None)
开发者ID:fish2000,项目名称:plotdevice,代码行数:13,代码来源:app.py

示例11: bring_to_front

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
def bring_to_front():
    global WINDOW_HANDLE
    if(sublime.platform() == 'osx'):
        if(SBApplication):
            subl_window = SBApplication.applicationWithBundleIdentifier_("com.sublimetext.2")
            subl_window.activate()
        else:
            os.system("/usr/bin/osascript -e '%s'" %
                      'tell app "Finder" to set frontmost of process "Sublime Text" to true')
    elif(sublime.platform() == 'linux'):
        import subprocess
        subprocess.call("wmctrl -xa '%s'" % WINDOW_HANDLE, shell=True)
开发者ID:KES777,项目名称:rsub,代码行数:14,代码来源:rsub.py

示例12: get_display_profile_path

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
def get_display_profile_path():
    if not hasattr(get_display_profile_path, 'profile_path'):
        import objc
        from ScriptingBridge import SBApplication
        ImageEvents = SBApplication.applicationWithBundleIdentifier_('com.apple.ImageEvents')
        #ImageEvents.activate()
        displays = ImageEvents.displays()
        if len(displays) < 1:
            get_display_profile_path.profile_path = None
        get_display_profile_path.profile_path = displays[0].displayProfile().location().properties()['POSIXPath']
        ImageEvents.quitSaving_(objc.NO)
    return get_display_profile_path.profile_path
开发者ID:fish2000,项目名称:plotdevice,代码行数:14,代码来源:__init__.py

示例13: enableshortcuts

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
 def enableshortcuts(self):
     self.apply()
     # popup System Preferences dialog
     try:
         # http://stackoverflow.com/questions/6652598/cocoa-button-opens-a-system-preference-page/6658201
         from ScriptingBridge import SBApplication
         sysprefs = 'com.apple.systempreferences'
         prefs = SBApplication.applicationWithBundleIdentifier_(sysprefs)
         pane = [x for x in prefs.panes() if x.id() == 'com.apple.preference.security'][0]
         prefs.setCurrentPane_(pane)
         anchor = [x for x in pane.anchors() if x.name() == 'Privacy_Accessibility'][0]
         anchor.reveal()
         prefs.activate()
     except:
         AXIsProcessTrustedWithOptions({kAXTrustedCheckOptionPrompt: True})
     self.parent.event_generate('<<Quit>>', when="tail")
开发者ID:Marginal,项目名称:EDMarketConnector,代码行数:18,代码来源:prefs.py

示例14: POST

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
 def POST(self):
     
     iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
     track = iTunes.currentTrack()
     
     i = web.input(submit = None)
     
     if i.submit == "play":
         iTunes.playpause()
     elif i.submit == "next":
         iTunes.nextTrack()
     elif i.submit == "prev":
         iTunes.previousTrack()
     
     web.header('Content-Type','text/html; charset=utf-8') 
     return render.nowplaying(track=track, iTunes=iTunes, len=len)
开发者ID:vinc3m1,项目名称:nowplaying,代码行数:18,代码来源:code.py

示例15: delete_file

# 需要导入模块: from ScriptingBridge import SBApplication [as 别名]
# 或者: from ScriptingBridge.SBApplication import applicationWithBundleIdentifier_ [as 别名]
def delete_file(fpath):
    """On OS X: Trashes a path using the Finder, via OS X's Scripting Bridge.

    On other platforms: unlinks file.
    """

    try:
        from AppKit import NSURL
        from ScriptingBridge import SBApplication
    except ImportError:
        log().debug("Deleting %r" % fpath)
        os.unlink(fpath)
    else:
        log().debug("Trashing %r" % fpath)
        targetfile = NSURL.fileURLWithPath_(fpath)
        finder = SBApplication.applicationWithBundleIdentifier_("com.apple.Finder")
        items = finder.items().objectAtLocation_(targetfile)
        items.delete()
开发者ID:shaleh,项目名称:tvnamer,代码行数:20,代码来源:utils.py


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