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

Python webbrowser.open_new函数代码示例

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

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



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

示例1: openweb

 def openweb(self, *args):
     """
     Open wikipedia url
     """
     url = self.main.url_to_open
     if url:
         webbrowser.open_new(url)
开发者ID:jhautefeuille,项目名称:atomeid,代码行数:7,代码来源:main.py


示例2: view_cdn_in_browser

    def view_cdn_in_browser(self):
        """
        Let's prove that we've successfully cached the object on the CDN by
        opening {object_name} on the CDN: http://{bucket_name}.{alias}.netdna-cdn.com/{object_name}
        """

        webbrowser.open_new("http://%s/%s" % (self.cdn_url, self.object_name))
开发者ID:MaxCDN,项目名称:dreamobjects-maxcdn,代码行数:7,代码来源:demo.py


示例3: reportBug

 def reportBug(self, event):
     # open the browser window to the New Issue tracker page
     webbrowser.open_new("http://roundup.creativecommons.org/ccpublisher/[email protected]=item")
     
     return
 
     
     # load the dialog definition
     xrc_resource = wx.xrc.XmlResource(os.path.join(
         p6.api.getResourceDir(), 'dialogs.xrc'))
     report = xrc_resource.LoadDialog(None, "DLG_BUGREPORT")
     
     # connect the OK button
     self.Bind(wx.EVT_BUTTON,
               self.__reportBug,
               id = wx.xrc.XRCID("CMD_OK")
               )
     
     # connect the Cancel button
     self.Bind(wx.EVT_BUTTON,
               lambda event: report.Close(),
               id = wx.xrc.XRCID("CMD_CANCEL")
               )
               
     # display the dialog
     self.__reportDlg = report
     report.ShowModal()
开发者ID:BackupTheBerlios,项目名称:cctools-svn,代码行数:27,代码来源:wxpy.py


示例4: setUpClass

 def setUpClass(self):
   super(BrowserCore, self).setUpClass()
   self.harness_queue = multiprocessing.Queue()
   self.harness_server = multiprocessing.Process(target=harness_server_func, args=(self.harness_queue,))
   self.harness_server.start()
   print '[Browser harness server on process %d]' % self.harness_server.pid
   webbrowser.open_new('http://localhost:9999/run_harness')
开发者ID:Chingliu,项目名称:emscripten,代码行数:7,代码来源:runner.py


示例5: fetch_train_tickets

def fetch_train_tickets(from_station, to_station, date=None, train_type=None):
    """get input data and print final result

    :param train_type
    :param from_station
    :param to_station
    :param date
    :return: if data is invalidate then return False
    """
    date = tickets_util.validate_raw_date(date)

    if not isinstance(date, str):
        print(common_util.make_colorful_font(date['message'], Fore.RED))
        return date['result']

    from_station_key = tickets_util.get_station_key(from_station)
    to_station_key = tickets_util.get_station_key(to_station)

    fetch_url = URL.format(date=date, from_station_key=from_station_key, to_station_key=to_station_key)
    train_tickets = fetch_trains.TrainTickets(fetch_url)
    tickets_result = train_tickets.fetch_tickets()

    # with open('./data/tickets_data.json', encoding="utf-8") as f:
    #     tickets_result = json.loads(f.read())

    if tickets_result['result']:
        print_train_tickets(tickets_result['data'], train_type)
    else:
        print(common_util.make_colorful_font(tickets_result['message'], Fore.RED))
        return False
    determine_input = input('到官网购票? y/n ')
    if determine_input == 'y':
        webbrowser.open_new(OFFICIAL_WEB)
开发者ID:ecmadao,项目名称:Train-12306,代码行数:33,代码来源:trains.py


示例6: report_dispatcher

def report_dispatcher(args=sys.argv[1:]):
    """Parses command line and calls the different report functions

    """

    command = command_handling(args, COMMAND_LOG)

    # Parses command line arguments.
    command_args = a.parse_and_check(command)

    port = DEFAULT_PORT if not command_args.port else command_args.port
    report_url = get_report_url(command_args)
    if not command_args.no_server:
        absolute_report_url = "http://%s:%s/%s" % (DEFAULT_HOST, port, report_url)
        current_directory = os.getcwd()
        os.chdir(os.path.join(HOME, SERVER_DIRECTORY))
        httpd = None
        try:
            httpd = StoppableHTTPServer((DEFAULT_HOST, port), SimpleHTTPServer.SimpleHTTPRequestHandler)
            thread.start_new_thread(httpd.serve, ())
        except socket.error, exc:
            print exc
        # Open URL in new browser window
        webbrowser.open_new(absolute_report_url)
        # opens in default browser
        if httpd:
            raw_input(
                "*********************************\n"
                "Press <RETURN> to stop the server\n"
                "*********************************\n"
            )
        os.chdir(current_directory)
        if httpd:
            httpd.stop()
开发者ID:ASA-Pitts,项目名称:bigmler,代码行数:34,代码来源:dispatcher.py


示例7: get_new_vk_token

def get_new_vk_token():
    SocketServer.TCPServer.allow_reuse_address = True
    httpd = None
    redirect_port = 20938
    while httpd is None:
        try:
            httpd = SocketServer.TCPServer(("", redirect_port), HttpHandler)
            print 'Server is running on port %d.' % redirect_port
        except socket.error:
            print 'Port %d is already in use. Trying next port.' % redirect_port
            redirect_port += 1

    parameters = {
        'client_id': APP_ID,
        'scope': 'audio',
        'redirect_uri': 'http://localhost:%d' % redirect_port,
        'display': 'page',
        'v': 5.37,
        'response_type': 'token'
    }
    auth_url = "https://oauth.vk.com/authorize?{}".format(urlencode(parameters))

    webbrowser.open_new(auth_url)

    httpd.handle_request()
    httpd.handle_request()
    token_object = dict()
    token_object['access_token'] = TOKEN['#access_token'][0]
    token_expires_in = int(TOKEN['expires_in'][0])
    token_object['expiring_time'] = int(time.time()) + token_expires_in - 60
    return token_object
开发者ID:kakty3,项目名称:radium-lover,代码行数:31,代码来源:main.py


示例8: getKey

def getKey(YD_APP_ID, YD_APP_SECRET, keyfile):
    if os.path.isfile(keyfile):
        return open(keyfile, 'r').read()
    import webbrowser
    webbrowser.open_new(
        OAYR + 'authorize?response_type=code&client_id=' + YD_APP_ID)

    YploadRequestHandler._code = None
    httpd = BaseHTTPServer.HTTPServer(('', 8714), YploadRequestHandler)
    httpd.handle_request()

    if YploadRequestHandler._code:
        code = YploadRequestHandler._code
    else:
        code = raw_input('Input your code: ').strip()

    res = requests.post(OAYR + 'token', data=dict(
        grant_type='authorization_code',
        code=code,
        client_id=YD_APP_ID, client_secret=YD_APP_SECRET
    ))
    if res.status_code != 200:
        raise Exception('Wrong code')
    key = res.json['access_token']
    with open(keyfile, 'w') as fl:
        fl.write(key)
    return key
开发者ID:spoterianski,项目名称:ypload,代码行数:27,代码来源:ydisk.py


示例9: publish

def publish(connection, document, bucket, theme, prefix=None, title=None):
    bucket = connection.get_bucket(bucket)

    key_name = document.name

    if '.' in key_name:
        key_name = key_name.rsplit('.', 1)[0] + '.html'
    if '/' in key_name:
        key_name = key_name.rsplit('/', 1)[1]

    if prefix:
        key_name = '%s/%s' % (prefix, key_name)

    content = __template__ % {
        'title': title if title else key_name,
        'content': document.read(),
        'theme': theme
    }

    key = bucket.new_key(key_name)
    key.content_type = 'text/html'
    key.set_contents_from_string(content)
    key.set_canned_acl('public-read')

    public_url = key.generate_url(0, query_auth=False, force_http=True)

    os.system('echo "%s" | pbcopy' % public_url)
    webbrowser.open_new(public_url)
开发者ID:Thingee,项目名称:dropkick,代码行数:28,代码来源:document.py


示例10: prepare_run

    def prepare_run(self, workspace):
        '''Invoke the image_set_list pickling mechanism and save the pipeline'''

        pipeline = workspace.pipeline
        image_set_list = workspace.image_set_list

        if pipeline.test_mode or self.from_old_matlab:
            return True
        if self.batch_mode.value:
            self.enter_batch_mode(workspace)
            return True
        else:
            path = self.save_pipeline(workspace)
            if not cpprefs.get_headless():
                import wx
                wx.MessageBox(
                        "CreateBatchFiles saved pipeline to %s" % path,
                        caption="CreateBatchFiles: Batch file saved",
                        style=wx.OK | wx.ICON_INFORMATION)
            if self.go_to_website:
                try:
                    import webbrowser
                    import urllib
                    server_path = self.alter_path(os.path.dirname(path))
                    query = urllib.urlencode(dict(data_dir=server_path))
                    url = cpprefs.get_batchprofiler_url() + \
                          "/NewBatch.py?" + query
                    webbrowser.open_new(url)
                except:
                    import traceback
                    traceback.print_exc()
            return False
开发者ID:zindy,项目名称:CellProfiler,代码行数:32,代码来源:createbatchfiles.py


示例11: authorize

    def authorize(self, account):
        self.account = account

        if account == "twitter":
            self.api = self.TWITTER
        elif account == "identi.ca":
            self.api = self.IDENTICA
        else:
            self.api = self.GETGLUE

        self.request_token = None

        key = base64.b64decode(self.api["key"])
        secret = base64.b64decode(self.api["secret"])

        self.consumer = oauth.Consumer(key, secret)
        client = oauth.Client(self.consumer, proxy_info=self.proxy_info)

        resp, content = client.request(self.api["request_token"])

        if resp["status"] != "200":
            self.note_label.set_text(content)
            return False

        self.request_token = dict(urlparse.parse_qsl(content))

        url = "%s?oauth_token=%s" % (self.api["authorization"], self.request_token["oauth_token"])
        self.note_label.set_markup("Opening authorize link in default web browser.")
        webbrowser.open_new(url)
        return True
开发者ID:jayrambhia,项目名称:rhythmbox-microblogger,代码行数:30,代码来源:microblogger.py


示例12: URL_click

def URL_click(event):
    if not len(listbox.curselection()) == 0:
        currentPackage = packageDescription()
        for package in allPackages:
            if package.name ==listbox.get(listbox.curselection()):
                currentPackage = package
        webbrowser.open_new(currentPackage.homepage)
开发者ID:brics,项目名称:brocre,代码行数:7,代码来源:package_installer.py


示例13: make

    def make(self):
        helper_in_cwd = exists(join(self.dir, "googlecode_upload.py"))
        if helper_in_cwd:
            sys.path.insert(0, self.dir)
        try:
            import googlecode_upload
        except ImportError:
            raise MkError("couldn't import `googlecode_upload` (get it from http://support.googlecode.com/svn/trunk/scripts/googlecode_upload.py)")
        if helper_in_cwd:
            del sys.path[0]

        ver = _get_version()
        sdist_path = join(self.dir, "dist", "go-%s.zip" % ver)
        status, reason, url = googlecode_upload.upload_find_auth(
            sdist_path,
            "go-tool", # project_name
            "go %s source package" % ver, # summary
            ["Featured", "Type-Archive"]) # labels
        if not url:
            raise MkError("couldn't upload sdist to Google Code: %s (%s)"
                          % (reason, status))
        self.log.info("uploaded sdist to `%s'", url)

        project_url = "http://code.google.com/p/go-tool/"
        import webbrowser
        webbrowser.open_new(project_url)
开发者ID:davidascher,项目名称:go-tool,代码行数:26,代码来源:Makefile.py


示例14: on_decide_policy

def on_decide_policy(view, decision, dtype):
    uri = decision.get_request().get_uri()
    if uri.startswith("http") and not '127.0.0.1' in uri:
        decision.ignore()
        webbrowser.open_new(uri)
        return True
    return False
开发者ID:h4ck3rm1k3,项目名称:openmedialibrary,代码行数:7,代码来源:gtkwebkit.py


示例15: do_lexhtml

    def do_lexhtml(self, subcmd, opts, lang, path):
        """${cmd_name}: lex the given file to styled HTML (for debugging)

        ${cmd_usage}
        ${cmd_option_list}
        """
        from ludditelib.debug import lex_to_html
        content = open(path, 'r').read()
        html = lex_to_html(content, lang)

        if opts.output == '-':
            output_path = None
            output_file = sys.stdout
        else:
            if opts.output:
                output_path = opts.output
            else:
                output_path = path+".html"
            if exists(output_path):
                os.remove(output_path)
            output_file = open(output_path, 'w')
        if output_file:
            output_file.write(html)
        if output_path:
            output_file.close()

        if opts.browse:
            if not output_path:
                raise LudditeError("cannot open in browser if stdout used "
                                   "for output")
            import webbrowser
            url = _url_from_local_path(output_path)
            webbrowser.open_new(url)            
开发者ID:Acidburn0zzz,项目名称:KomodoEdit,代码行数:33,代码来源:luddite.py


示例16: run

 def run(self):
     view_id = sublime.active_window().active_view().id()
     if not issue_obj_storage.empty():
         issue_obj = utils.show_stock(issue_obj_storage, view_id)
         url = issue_obj["issue"]["html_url"]
         if url:
             webbrowser.open_new(url)
开发者ID:divinites,项目名称:gissues,代码行数:7,代码来源:github_issue.py


示例17: go_to_button

    def go_to_button(self, sender, e):

        if self.user_data["name_url"]:
            if spk_page in self.user_data["name_url"]:
                webbrowser.open_new(self.user_data["name_url"])
        else:
            webbrowser.open_new(spk_page + "/my-cloud")
开发者ID:utitankaspk,项目名称:SPKCAM,代码行数:7,代码来源:spkcam_ui.py


示例18: check_credentials

def check_credentials():
    """
    Check credentials and spawn server and browser if not
    """
    credentials = get_credentials()
    if not credentials or "https://www.googleapis.com/auth/drive" not in credentials.config["google"]["scope"]:
        try:
            with open(os.devnull, "w") as fnull:
                print "Credentials were not found or permissions were not correct. Automatically opening a browser to authenticate with Google."
                gunicorn = find_executable("gunicorn")
                process = subprocess.Popen(
                    [gunicorn, "-b", "127.0.0.1:8888", "app:wsgi_app"], stdout=fnull, stderr=fnull
                )
                webbrowser.open_new("http://127.0.0.1:8888/oauth")
                print "Waiting..."
                while not credentials:
                    try:
                        credentials = get_credentials()
                        sleep(1)
                    except ValueError:
                        continue
                print "Successfully authenticated!"
                process.terminate()
        except KeyboardInterrupt:
            print "\nCtrl-c pressed. Later, skater!"
            exit()
开发者ID:jimlondon,项目名称:my-new-awesome-project2,代码行数:26,代码来源:bootstrap.py


示例19: authorize

    def authorize(self):
        """ Does the OAuth conga. Opens browser window so that the user can authenticate.

        Returns: access_token, for further unattended use
        """
        oauth_request = oauth.OAuthRequest.from_consumer_and_token(
            self.client.consumer, http_url=self.client.request_token_url, http_method="POST"
        )
        oauth_request.sign_request(self.client.signature_method_plaintext, self.client.consumer, None)
        token = self.client.fetch_request_token(oauth_request)

        # Authorize access, get verifier
        url = self.client.authorize_token(oauth_request)
        webbrowser.open_new(url)

        verifier = raw_input("Please enter verifier:")

        # Now obtain access_token
        oauth_request = oauth.OAuthRequest.from_consumer_and_token(
            self.client.consumer, token=token, verifier=verifier, http_url=self.client.access_token_url
        )
        oauth_request.sign_request(self.client.signature_method_plaintext, self.client.consumer, token)
        token = self.client.fetch_access_token(oauth_request)

        self.access_token = token
        return self.access_token
开发者ID:ZNickq,项目名称:wouso-extras,代码行数:26,代码来源:wousoapi.py


示例20: displayhelp

def displayhelp(htmlfile,txtfile, helpname=None):
    """Open a browser with the html help file, failing that bring up
       a dialog with the help as a text file, or as a last resort direct
       the user to the online documentation.
    """

    #This holds the title for the widget
    if not helpname:
        helpname="CCP1GUI help"
        
    if sys.platform[:3] == 'win':
        txtpath = gui_path + '\\doc\\'
        htmlpath = gui_path+ '\\doc\\html\\'
    elif  sys.platform[:3] == 'mac':
        pass
    else:
        txtpath = gui_path + '/doc/'
        htmlpath =  gui_path + '/doc/html/'

    htmlfound = None
    browserr = None

    if validpath(htmlpath+htmlfile):
        #Check for file as no way of checking with webrowser
        htmlfound = 1
        try:
            url = "file://"+htmlpath+htmlfile
            webbrowser.open_new(url)
        except webbrowser.Error, (errno,msg):
            print "Browser Error: %s (%d)\n" % (msg,errno)
            print "Using widget instead."
            browserr = 1
开发者ID:alexei-matveev,项目名称:ccp1gui,代码行数:32,代码来源:help.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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