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


Python webbrowser.get函数代码示例

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


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

示例1: callback

    def callback(self, index):
        if index == -1:
            return

        command = self.cmds[index]
        self.view.run_command(command)

        if protocol and command == 'xdebug_listen':
            url = get_project_setting('url')
            if url:
                webbrowser.get(browser).open(url + '?XDEBUG_SESSION_START=sublime.xdebug')
            else:
                sublime.status_message('Xdebug: No URL defined in project settings file.')

            global original_layout
            global debug_view
            window = sublime.active_window()
            original_layout = window.get_layout()
            debug_view = window.active_view()
            window.set_layout({
                "cols": [0.0, 0.5, 1.0],
                "rows": [0.0, 0.7, 1.0],
                "cells": [[0, 0, 2, 1], [0, 1, 1, 2], [1, 1, 2, 2]]
            })

        if command == 'xdebug_clear':
            url = get_project_setting('url')
            if url:
                webbrowser.get(browser).open(url + '?XDEBUG_SESSION_STOP=sublime.xdebug')
            else:
                sublime.status_message('Xdebug: No URL defined in project settings file.')
            window = sublime.active_window()
            window.run_command('hide_panel', {"panel": 'output.xdebug_inspect'})
            window.set_layout(original_layout)
开发者ID:juco,项目名称:SublimeXdebug,代码行数:34,代码来源:Xdebug.py

示例2: show_plot

def show_plot():
    l = get_csv()
    f = len(l)-1
    value = []
    pro = []
    for r in range(0, 20):
        print l[r]
        value.append(l[r][1])
        pro.append(l[r][0])

    # 写入json
    data = {}
    data["categories"] = pro
    data["data"] = value
    j = json.dumps(data)
    print j

    with open('./html/data.js', 'wb') as f:
        co = 'var c=' + j
        f.write(co)

    # 写入图片
    '''
    pos = np.arange(len(value))
    plt.bar(pos, value, color=getColors(value), alpha=1)
    plt.show()
    '''

    # 打开网页
    webbrowser.get('C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe %s').open('../html/py.html')
开发者ID:belloving,项目名称:py1,代码行数:30,代码来源:jd_csv_matplot.py

示例3: play

	def play(self):
		self.start_time = time()

		""" Add game name to database after it's been started at least once """
		does_it_exist = dbase.execute("SELECT Name FROM games WHERE Name = '%s'" % self.game_name).fetchone()
		if does_it_exist is None:
			database.execute("INSERT INTO games (Name,Timewatched,AltName) VALUES ('%s',0,NULL)" % self.game_name)

		""" For conky output - Populate the miscellaneous table with the display name and start time """
		database.execute("INSERT INTO miscellaneous (Name,Value) VALUES ('%s','%s')" % (self.display_name, self.start_time))
		database.commit()

		if self.show_chat is True:
			try:
				webbrowser.get('chromium').open_new('--app=http://www.twitch.tv/%s/chat?popout=' % self.final_selection)
			except:
				webbrowser.open_new('http://www.twitch.tv/%s/chat?popout=' % self.final_selection)

		if self.channel_name_if_vod is None:
			print(' ' + Colors.WHITE + self.display_name + Colors.ENDC + ' | ' + Colors.WHITE + self.stream_quality.title() + Colors.ENDC)
			player_final = Options.player_final + ' --title ' + self.display_name.replace(' ', '')
			self.args_to_subprocess = "livestreamer twitch.tv/'{0}' '{1}' --player '{2}' --hls-segment-threads 3 --http-header Client-ID=guulhcvqo9djhuyhb2vi56wqnglc351".format(self.final_selection, self.stream_quality, player_final)
		else:
			print(' ' + Colors.WHITE + self.display_name + ': ' + self.video_title_if_vod + Colors.ENDC + ' | ' + Colors.WHITE + self.stream_quality.title() + Colors.ENDC)
			player_final = Options.player_final + ' --title ' + self.display_name
			self.args_to_subprocess = "livestreamer '{0}' '{1}' --player '{2}' --hls-segment-threads 3 --player-passthrough=hls --http-header Client-ID=guulhcvqo9djhuyhb2vi56wqnglc351".format(self.final_selection, self.stream_quality, player_final)

		self.args_to_subprocess = shlex.split(self.args_to_subprocess)
		self.livestreamer_process = subprocess.Popen(self.args_to_subprocess, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
开发者ID:BasioMeusPuga,项目名称:twitchy,代码行数:29,代码来源:twitchy.py

示例4: run

    def run(self):
        
        # Create a new manager object
        self.manager = BrowserManager()

        # Save the changes to the browser
        self.manager.saveFile()
                
        print "File saved\n"

        self.browserList = ["Internet Explorer", "FireFox", "Chrome", "Opera", "Safari"]
        self.window.show_quick_panel(self.browserList, None)

        print sublime.platform()

        # Get the domain to open
        for title, domain in self.manager.getDomainConfig().items():
            if self.manager.getSelectedDomain() == domain:
                url = domain + self.window.active_view().file_name()[16:len(self.window.active_view().file_name())]

        # Check to see if the file can be displayed in the browser
        if self.window.active_view().file_name().endswith(self.manager.getExtList()):
            if sublime.platform() == "windows":
                webbrowser.get('windows-default').open(url)
            else:
                webbrowser.open(url)
        else:
            print "\nThis is not a browsable file\n"
开发者ID:kamodev,项目名称:Browser-Plugin,代码行数:28,代码来源:Browser.py

示例5: main

def main():
    try:
        buildServer = run_local_build_server()
        while not is_build_server_running():
            print "[build server] BOOTING"
        print "[build server] ONLINE"

        appInventor = start_appinventor()
        while not is_app_inventor_running():
            print "[app inventor] BOOTING"
        print "[app inventor] ONLINE"

        print "[app inventor] OPENING"
        try:
            browser = webbrowser.get("chrome")
        except webbrowser.Error:
            try:
                webbrowser.register("firefox", None, webbrowser.GenericBrowser(os.environ["ProgramFiles"] + r"\Mozilla Firefox\firefox.exe"), 1)
                browser = webbrowser.get("firefox")
            except webbrowser.Error:
                browser = webbrowser.get()
        browser.open("http://localhost:8888/_ah/login?continue=http://localhost:8888/")
    except Exception as e:
        print type(e)
        print e
    finally:
        taskkill(buildServer.pid)
        taskkill(appInventor.pid)
开发者ID:JacobAMason,项目名称:FTCDevSuite,代码行数:28,代码来源:run_App_Inventor.py

示例6: launch_browser

def launch_browser(port,preferred_browser=None):
    ''' try to use preferred browser if specified, fall back to default 
    '''
    url = 'http://localhost:'+str(port)    
    print 'Opening URL in browser: '+url+' (pid='+str(os.getpid())+')'
    
    # webbrowser doesn't know about chrome, so try to find it (this is for win7)
    if preferred_browser and preferred_browser.lower() == 'chrome':
        USERPROFILE = os.getenv("USERPROFILE")
        if USERPROFILE:
            CHROMEPATH = USERPROFILE+'\AppData\Local\Google\Chrome\Application\chrome.exe'
       	    if os.path.isfile(CHROMEPATH):
                preferred_browser = CHROMEPATH.replace('\\','\\\\')+' --app=%s'
    
    # try to get preferred browser, fall back to default
    if preferred_browser:
        try:
            browser = webbrowser.get(preferred_browser);
        except:
            print "Couldn't get preferred browser ("+preferred_browser+"), using default..."
            browser = webbrowser.get()
    else:
        browser = webbrowser.get()
    
    # open new browser window (may open in a tab depending on user preferences, etc.)
    if browser:
        browser.open(url,1,True)
        print "Opened in",browser.name
    else:
        print "Couldn't launch browser: "+str(browser)
开发者ID:OzanCKN,项目名称:OpenMDAO-Framework,代码行数:30,代码来源:mdao_util.py

示例7: prefs

 def prefs(self):
     daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
     try:
         daemon.is_running()
         webbrowser.get('safari').open("lbry://settings")
     except:
         rumps.notification(title='LBRY', subtitle='', message="Couldn't connect to lbrynet daemon", sound=True)
开发者ID:whitslack,项目名称:lbry,代码行数:7,代码来源:LBRYOSXStatusBar.py

示例8: launchBrowser

def launchBrowser():
    # wait for server to start starting...
    while not serverStarted:
        time.sleep(0.001)

    # wait for server to finish starting
    time.sleep(1.0)

    # search for port in server's config file
    serverPort = DEFAULT_PORT
    with open("server.cfg", 'r') as f:
        contents = f.read()
        position = string.find(contents, "port=")
        if position != -1:
            position += 5
            portStr = contents[position:].split()[0]
            try:
                serverPort = int(portStr)
            except:
                serverPort = DEFAULT_PORT

    # open the web browser (Firefox in Linux, user's preferred on Windows)
    if os.name == "posix":
        # will return default system's browser if Firefox is not installed
        controller = webbrowser.get('Firefox')
    else:
        controller = webbrowser.get('windows-default')

    url = "http://localhost"
    if serverPort != 80: url += ":" + str(serverPort)
    controller.open_new_tab(url)
开发者ID:KuanYuChen,项目名称:mansos,代码行数:31,代码来源:web_launcher.py

示例9: set_config

def set_config():
    """Set optional API keys, browser, and bookmarks in CONFIG."""
    for key, val in iteritems(read_config()):
        CONFIG[key] = val

    if 'browser' in CONFIG and CONFIG['browser'] != 'Automatically detected':
        try:
            CONFIG['browser_obj'] = webbrowser.get(CONFIG['browser'])
            return
        except webbrowser.Error as err:
            sys.stderr.write('{} at {}\n'.format(str(err), CONFIG['browser']))
            CONFIG['browser_obj'] = None
            pass
        except IndexError:
            CONFIG['browser_obj'] = None
            pass

    # If no valid browser found then use webbrowser to automatically detect one
    try:
        supported_platforms = {'win32': 'windows-default', 'cygwin': 'cygstart', 'darwin': 'macosx'}
        if sys.platform not in supported_platforms:
            browser_name = 'Automatically detected'
            browser_obj = webbrowser.get()
        else:
            browser_name = supported_platforms[sys.platform]
            if browser_name == 'cygstart':
                # Cygwin requires us to register browser type (or export BROWSER='cygstart')
                webbrowser.register(browser_name, None, webbrowser.GenericBrowser(browser_name))
            browser_obj = webbrowser.get(browser_name)

        CONFIG['browser'] = browser_name
        CONFIG['browser_obj'] = browser_obj
    except webbrowser.Error:
        pass
开发者ID:huntrar,项目名称:cliquery,代码行数:34,代码来源:config.py

示例10: keypress

 def keypress(self, size, key):
     if key in {'down', 'n', 'N'}:
         self.answer_text.next_ans()
     elif key in {'up', 'b', 'B'}:
         self.answer_text.prev_ans()
     elif key in {'o', 'O'}:
         import webbrowser
         if sys.platform.startswith('darwin'):
             browser = webbrowser.get('safari')
         else:
             browser = webbrowser.get()
         print_warning("Opening in your browser...")
         browser.open(self.url)
     elif key == 'left':
         global question_post
         global question_page
         question_post = None
         if question_page is None:
             sys.exit(0)
         else:
             LOOP.widget = question_page
     elif key == 'window resize':
         screenHeight, screenWidth = subprocess.check_output(['stty', 'size']).split()
         if self.screenHeight != screenHeight:
             self._invalidate()
             answer_frame = self.makeFrame(self.data)
             urwid.WidgetWrap.__init__(self, answer_frame)
开发者ID:gitter-badger,项目名称:socli,代码行数:27,代码来源:socli.py

示例11: treeherder

def treeherder(ui, repo, tree=None, rev=None, **opts):
    """Open Treeherder showing build status for the specified revision.

    The command receives a tree name and a revision to query. The tree is
    required because a revision/changeset may existing in multiple
    repositories.
    """
    if not tree:
        raise util.Abort('A tree must be specified.')

    if not rev:
        raise util.Abort('A revision must be specified.')

    tree, repo_url = resolve_trees_to_uris([tree])[0]
    if not repo_url:
        raise util.Abort("Don't know about tree: %s" % tree)

    r = MercurialRepository(repo_url)
    node = repo[rev].hex()
    push = r.push_info_for_changeset(node)

    if not push:
        raise util.Abort("Could not find push info for changeset %s" % node)

    push_node = push.last_node

    url = treeherder_url(tree, push_node[0:12])

    import webbrowser
    webbrowser.get('firefox').open(url)
开发者ID:armenzg,项目名称:version-control-tools,代码行数:30,代码来源:__init__.py

示例12: main

def main():
    # configure server
    static_dirs = PELICAN_SETTINGS['STATIC_PATHS'] + [PELICAN_SETTINGS['THEME']]
    config = {
        '/' + static_dir: {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(OUTPUT_PATH, static_dir)}
        for static_dir in static_dirs}
    cherrypy.config.update({'engine.autoreload.on': False})
    if not DEBUG:
        cherrypy.config.update({'log.screen': False})
    cherrypy.tree.mount(CherrypyServer(), '/', config=config)

    # configure observer
    global OBSERVER
    OBSERVER = PausingObserver()
    OBSERVER.schedule(PelicanUpdater(), PELICAN_PATH, recursive=True)

    # start threads
    cherrypy.engine.start()
    OBSERVER.start()
    if BROWSER:
        webbrowser.get(BROWSER).open('http://127.0.0.1:8080')

    # control loop
    while True:
        try:
            time.sleep(1)
        except KeyboardInterrupt:
            break

    # teardown
    OBSERVER.stop()
    os._exit(0)
开发者ID:ryneeverett,项目名称:pelican_dev_server,代码行数:34,代码来源:main.py

示例13: plot_sys_tree

def plot_sys_tree(system, outfile=None, fmt='pdf'):
    """
    Generate a plot of the system tree and bring it up in a browser.
    (requires graphviz).

    Args
    ----
    system : `System`
        Starting node of the System tree to be plotted.

    outfile : str, optional
        Name of the output file.  Default is 'system_tree.<fmt>'

    fmt : str, optional
        Format for the plot file. Any format accepted by dot should work.
        Default is 'pdf'.
    """
    if outfile is None:
        outfile = 'system_tree.'+fmt

    dotfile = os.path.splitext(outfile)[0]+'.dot'

    _write_system_dot(system, dotfile)

    os.system("dot -T%s -o %s %s" % (fmt, outfile, dotfile))

    if sys.platform == 'darwin':
        os.system('open %s' % outfile)
    else:
        webbrowser.get().open(outfile)

    try:
        os.remove(dotfile)
    except:
        pass
开发者ID:wuwei205,项目名称:OpenMDAO,代码行数:35,代码来源:dotgraph.py

示例14: show

 def show(self, browser=None):
     scalar = 200./10
     # origin = (210, 210)
     dot_size = 3
     origin = 210
     hpath = create_temp('.html')
     with open(hpath, 'w') as h:
         h.writelines(
             ['<!DOCTYPE html>\n'
             ,'<head>\n'
             ,'<title>plot</title>\n'
             ,'</head>\n'
             ,'<body>\n'
             ,'<svg height="420" width=420 xmlns="http://www.w3.org/2000/svg">\n'
             ,'<line x1="0" y1="210" x2="420" y2="210"'
             ,'style="stroke:rgb(0,0,0);stroke-width:2"/>\n'
             ,'<line x1="210" y1="0" x2="210" y2="420"'
             ,'style="stroke:rgb(0,0,0);stroke-width:2"/>\n'])
         for line in self.lines:
             pt1, pt2 = self.lines[line][0]
             c = self.lines[line][1]
             x1, y1 = pt1
             x2, y2 = pt2
             h.writelines(['<line x1="%d" y1="%d" x2="%d" y2="%d" style="stroke:%s";stroke-width:2"/>\n'
                           % (origin+x1*scalar,origin-y1*scalar,origin+x2*scalar,origin-y2*scalar,c)])
         for pts in self.points:
             pt = self.points[pts]
             x,y = pt
             h.writelines(['<circle cx="%d" cy="%d" r="%d" fill="red"/>\n'
                         % (origin+scalar*x,origin-scalar*y,dot_size)])
         h.writelines(['</svg>\n</body>\n</html>'])
     if browser is None:
         browser = _browser
     webbrowser.get(browser).open('file://%s' % hpath)
开发者ID:grogs84,项目名称:nwspa,代码行数:34,代码来源:plotting.py

示例15: plot

def plot(L, scale=4, dot_size = 3, browser=None):
    """ plot takes a list of points, optionally a scale (relative to a 200x200 frame),
        optionally a dot size (diameter) in pixels, and optionally a browser name.
        It produces an html file with SVG representing the given plot,
        and opens the file in a web browser. It returns nothing.
    """
    scalar = 200./scale
    origin = (210, 210)
    hpath = create_temp('.html')
    with open(hpath, 'w') as h:
        h.writelines(
            ['<!DOCTYPE html>\n'
            ,'<head>\n'
            ,'<title>plot</title>\n'
            ,'</head>\n'
            ,'<body>\n'
            ,'<svg height="420" width=420 xmlns="http://www.w3.org/2000/svg">\n'
            ,'<line x1="0" y1="210" x2="420" y2="210"'
            ,'style="stroke:rgb(0,0,0);stroke-width:2"/>\n'
            ,'<line x1="210" y1="0" x2="210" y2="420"'
            ,'style="stroke:rgb(0,0,0);stroke-width:2"/>\n'])
        for pt in L:
            if isinstance(pt, Number):
                x,y = pt.real, pt.imag
            else:
                if isinstance(pt, tuple) or isinstance(pt, list):
                    x,y = pt
                else:
                    raise ValueError
            h.writelines(['<circle cx="%d" cy="%d" r="%d" fill="red"/>\n'
                          % (origin[0]+scalar*x,origin[1]-scalar*y,dot_size)])
        h.writelines(['</svg>\n</body>\n</html>'])
    if browser is None:
        browser = _browser
    webbrowser.get(browser).open('file://%s' % hpath)
开发者ID:grogs84,项目名称:nwspa,代码行数:35,代码来源:plotting.py


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