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


Python webbrowser.get方法代码示例

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


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

示例1: start_browser

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def start_browser(self, url, name=None):
        browser = None

        if name is not None and name.lower() == 'none':
            log.info('Will not start any browser since --browser=none')
            return

        try:
            browser = webbrowser.get(name)
        except webbrowser.Error:
            old     = name or 'default'
            msg     = 'Could not find browser: %s.  Will use: %s.'
            browser = webbrowser.get()
            log.warn(msg, name, self.getBrowserName(browser))

        if type(browser) is webbrowser.GenericBrowser:
            msg = 'Will not start text-based browser: %s.'
            log.info(msg % self.getBrowserName(browser))
        elif browser is not None:
            log.info('Starting browser: %s' % self.getBrowserName(browser))
            browser.open_new(url) 
开发者ID:NASA-AMMOS,项目名称:AIT-Core,代码行数:23,代码来源:openmct.py

示例2: do_GET

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def do_GET(self):
        params = urlparse.parse_qs(urlparse.urlparse(self.path).query)
        key = params.get('apikey')
        if not key:
            self.send_response(400)
            return

        self.server.key_queue.put(key[0])

        self.send_response(200)
        self.send_header('Access-Control-Allow-Origin', '*')
        self.send_header('Access-Control-Allow-Methods', 'GET, OPTIONS')
        self.send_header('Content-type', 'text/html')
        self.end_headers()

        page_content = ("""
            <html>
            <header>
             <script>
               window.location.replace("%s/cli_login?keystate=sent");
             </script>
            </header>
            </html>
        """ % (floyd.floyd_web_host)).encode('utf-8')
        self.wfile.write(page_content) 
开发者ID:floydhub,项目名称:floyd-cli,代码行数:27,代码来源:login.py

示例3: sf_oauth2

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def sf_oauth2(sf_basic_config):
    sublconsole = SublConsole(sf_basic_config)
    settings =  sf_basic_config.get_setting()
    from SalesforceXyTools.libs import auth
    project_setting = settings
    # project_setting = settings["default_project_value"]
    is_sandbox = project_setting["is_sandbox"]

    if refresh_token(sf_basic_config):
        return

    server_info = sublime.load_settings("sfdc.server.sublime-settings")
    client_id = server_info.get("client_id")
    client_secret = server_info.get("client_secret")
    redirect_uri = server_info.get("redirect_uri")
    oauth = auth.SalesforceOAuth2(client_id, client_secret, redirect_uri, is_sandbox)
    authorize_url = oauth.authorize_url()
    sublconsole.debug('authorize_url-->')
    sublconsole.debug(authorize_url)
    start_server()
    open_in_default_browser(sf_basic_config, authorize_url) 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:23,代码来源:util.py

示例4: reload

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def reload(self):
        self.sublconsole.showlog("start to reload metadata cache, please wait...")
        self.clean()
        allMetadataResult = self.meta_api.describe()
        
        allMetadataMap = {}
        allMetadataMap["sobjects"] = {}
        for meta in allMetadataResult["sobjects"]:
            name = meta["name"]
            allMetadataMap["sobjects"][name] = meta
        allMetadataMap["lastUpdated"] = str(datetime.now())
        self.save_dict(allMetadataMap)
        self.sublconsole.showlog("load metadata cache done.")
        # self.sublconsole.save_and_open_in_panel(json.dumps(allMetadataMap, ensure_ascii=False, indent=4), self.save_dir, self.file_name , is_open=False)

    # get all fields from sobject 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:18,代码来源:util.py

示例5: open_in_browser

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def open_in_browser(sf_basic_config, url, browser_name = '', browser_path = ''):
    settings =  sf_basic_config.get_setting()
    if not browser_path or not os.path.exists(browser_path) or browser_name == "default":
        webbrowser.open_new_tab(url)

    elif browser_name == "chrome-private":
        # os.system("\"%s\" --incognito %s" % (browser_path, url))
        browser = webbrowser.get('"' + browser_path +'" --incognito %s')
        browser.open(url)
        
    else:
        try:
            # show_in_panel("33")
            # browser_path = "\"C:\Program Files\Google\Chrome\Application\chrome.exe\" --incognito"
            webbrowser.register('chromex', None, webbrowser.BackgroundBrowser(browser_path))
            webbrowser.get('chromex').open_new_tab(url)
        except Exception as e:
            webbrowser.open_new_tab(url) 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:20,代码来源:util.py

示例6: _get_browser_controller

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def _get_browser_controller() -> webbrowser.BaseBrowser:

        if get_user_preference("browser") is not None:
            try:
                return webbrowser.get(using=get_user_preference("browser"))
            except webbrowser.Error:
                warnings.warn("Could not find the user preferred browser.")

        for browser in ["chrome", "chromium-browser"]:
            try:
                return webbrowser.get(using=browser)
            except webbrowser.Error:
                pass

        # Return default browser if none of the
        # preferred browsers are installed:
        return webbrowser.get() 
开发者ID:equinor,项目名称:webviz-config,代码行数:19,代码来源:_localhost_open_browser.py

示例7: _app_ready

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def _app_ready(self) -> bool:
        """Check if the flask instance is ready.
        """

        no_proxy_env = os.environ.get("NO_PROXY")
        os.environ["NO_PROXY"] = "localhost"

        try:
            urllib.request.urlopen(self._url(https=False))  # nosec
            app_ready = True
        except urllib.error.URLError:  # type: ignore[attr-defined]
            # The flask instance has not started
            app_ready = False
        except ConnectionResetError:
            # The flask instance has started but (correctly) abort
            # request due to "401 Unauthorized"
            app_ready = True
        finally:
            os.environ["NO_PROXY"] = no_proxy_env if no_proxy_env else ""

        return app_ready 
开发者ID:equinor,项目名称:webviz-config,代码行数:23,代码来源:_localhost_open_browser.py

示例8: _mathjax_url_default

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def _mathjax_url_default(self):
        if not self.enable_mathjax:
            return u''
        static_url_prefix = self.webapp_settings.get("static_url_prefix",
                         url_path_join(self.base_project_url, "static")
        )
        try:
            mathjax = filefind(os.path.join('mathjax', 'MathJax.js'), self.static_file_path)
        except IOError:
            if self.certfile:
                # HTTPS: load from Rackspace CDN, because SSL certificate requires it
                base = u"https://c328740.ssl.cf1.rackcdn.com"
            else:
                base = u"http://cdn.mathjax.org"
            
            url = base + u"/mathjax/latest/MathJax.js"
            self.log.info("Using MathJax from CDN: %s", url)
            return url
        else:
            self.log.info("Using local MathJax from %s" % mathjax)
            return url_path_join(static_url_prefix, u"mathjax/MathJax.js") 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:notebookapp.py

示例9: open_in_browser

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def open_in_browser(file_location):
    """Attempt to open file located at file_location in the default web
    browser."""

    # If just the name of the file was given, check if it's in the Current
    # Working Directory.
    if not os.path.isfile(file_location):
        file_location = os.path.join(os.getcwd(), file_location)
    if not os.path.isfile(file_location):
        raise IOError("\n\nFile not found.")

    #  For some reason OSX requires this adjustment (tested on 10.10.4)
    if sys.platform == "darwin":
        file_location = "file:///"+file_location

    new = 2  # open in a new tab, if possible
    webbrowser.get().open(file_location, new=new) 
开发者ID:mathandy,项目名称:svgpathtools,代码行数:19,代码来源:misctools.py

示例10: get_question_stats_and_answer

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def get_question_stats_and_answer(url):
    """
    Fetch the content of a StackOverflow page for a particular question.
    :param url: full url of a StackOverflow question
    :return: tuple of ( question_title, question_desc, question_stats, answers )
    """
    random_headers()
    res_page = requests.get(url, headers=header)
    captcha_check(res_page.url)
    soup = BeautifulSoup(res_page.text, 'html.parser')
    question_title, question_desc, question_stats = get_stats(soup)
    answers = [s.get_text() for s in soup.find_all("div", class_="post-text")][
              1:]  # first post is question, discard it.
    if len(answers) == 0:
        answers.append('No answers for this question ...')
    return question_title, question_desc, question_stats, answers 
开发者ID:gautamkrishnar,项目名称:socli,代码行数:18,代码来源:search.py

示例11: execute

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def execute(self, context):
        user_preferences = context.preferences
        addon_prefs = user_preferences.addons[metaverse_tools.__name__].preferences

        if not "gateway_server" in addon_prefs.keys():
            addon_prefs["gateway_server"] = default_gateway_server

        server = addon_prefs["gateway_server"]

        browsers = webbrowser._browsers
        # Better way would be to use jwt, but this is just a proto
        routes = GatewayClient.routes(server)
        # TODO On failure this should return something else.

        path = routes["uploads"] + "?" + urlencode({'token': addon_prefs["gateway_token"],
                                                    'username': addon_prefs["gateway_username"]})
        if "windows-default" in browsers:
            print("Windows detected")
            webbrowser.get("windows-default").open(server + path)
        else:
            webbrowser.open(server + path)

        return {'FINISHED'}

# ----- 
开发者ID:Menithal,项目名称:Blender-Metaverse-Addon,代码行数:27,代码来源:__init__.py

示例12: module_run

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def module_run(self):
        key = self.keys.get('google_api')
        sources = self.query('SELECT COUNT(source), source FROM pushpins GROUP BY source')
        media_content, map_content = self.build_content(sources)
        meta_content = (self.options['latitude'], self.options['longitude'], self.options['radius'])
        # create the media report
        media_content = meta_content + media_content
        media_filename = self.options['media_filename']
        self.write_markup(os.path.join(self.data_path, 'template_media.html'), media_filename, media_content)
        self.output(f"Media data written to '{media_filename}'")
        # order the map_content tuple
        map_content = meta_content + map_content + (key,)
        order = [6, 4, 0, 1, 2, 3, 5]
        map_content = tuple([map_content[i] for i in order])
        # create the map report
        map_filename = self.options['map_filename']
        self.write_markup(os.path.join(self.data_path, 'template_map.html'), map_filename, map_content)
        self.output(f"Mapping data written to '{map_filename}'")
        # open the reports in a browser
        w = webbrowser.get()
        w.open(media_filename)
        time.sleep(2)
        w.open(map_filename) 
开发者ID:lanmaster53,项目名称:recon-ng-marketplace,代码行数:25,代码来源:pushpin.py

示例13: delete_col

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def delete_col(data_id, column):
    data = global_state.get_data(data_id)
    data = data[[c for c in data.columns if c != column]]
    curr_history = global_state.get_history(data_id) or []
    curr_history += ['df = df[[c for c in df.columns if c != "{}"]]'.format(column)]
    global_state.set_history(data_id, curr_history)
    dtypes = global_state.get_dtypes(data_id)
    dtypes = [dt for dt in dtypes if dt["name"] != column]
    curr_settings = global_state.get_settings(data_id)
    curr_settings["locked"] = [
        c for c in curr_settings.get("locked", []) if c != column
    ]
    global_state.set_data(data_id, data)
    global_state.set_dtypes(data_id, dtypes)
    global_state.set_settings(data_id, curr_settings)
    return jsonify(success=True) 
开发者ID:man-group,项目名称:dtale,代码行数:18,代码来源:views.py

示例14: rename_col

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def rename_col(data_id, column):
    rename = get_str_arg(request, "rename")
    data = global_state.get_data(data_id)
    if column != rename and rename in data.columns:
        return jsonify(error='Column name "{}" already exists!')

    data = data.rename(columns={column: rename})
    curr_history = global_state.get_history(data_id) or []
    curr_history += ["df = df.rename(columns={'%s': '%s'})" % (column, rename)]
    global_state.set_history(data_id, curr_history)
    dtypes = global_state.get_dtypes(data_id)
    dtypes = [
        dict_merge(dt, {"name": rename}) if dt["name"] == column else dt
        for dt in dtypes
    ]
    curr_settings = global_state.get_settings(data_id)
    curr_settings["locked"] = [
        rename if c == column else c for c in curr_settings.get("locked", [])
    ]
    global_state.set_data(data_id, data)
    global_state.set_dtypes(data_id, dtypes)
    global_state.set_settings(data_id, curr_settings)
    return jsonify(success=True) 
开发者ID:man-group,项目名称:dtale,代码行数:25,代码来源:views.py

示例15: data_export

# 需要导入模块: import webbrowser [as 别名]
# 或者: from webbrowser import get [as 别名]
def data_export(data_id):
    curr_settings = global_state.get_settings(data_id) or {}
    curr_dtypes = global_state.get_dtypes(data_id) or []
    data = run_query(
        global_state.get_data(data_id),
        build_query(data_id, curr_settings.get("query")),
        global_state.get_context_variables(data_id),
        ignore_empty=True,
    )
    data = data[
        [
            c["name"]
            for c in sorted(curr_dtypes, key=lambda c: c["index"])
            if c["visible"]
        ]
    ]
    tsv = get_str_arg(request, "tsv") == "true"
    file_ext = "tsv" if tsv else "csv"
    csv_buffer = export_to_csv_buffer(data, tsv=tsv)
    filename = build_chart_filename("data", ext=file_ext)
    return send_file(csv_buffer.getvalue(), filename, "text/{}".format(file_ext)) 
开发者ID:man-group,项目名称:dtale,代码行数:23,代码来源:views.py


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