Python webbrowser.open_new() Examples

The following are 30 code examples of webbrowser.open_new(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module webbrowser , or try the search function .
Example #1
Source File: web.py    From svviz with MIT License 6 votes vote down vote up
def run(port=None):
    import webbrowser, threading

    if port is None:
        port = getRandomPort()

    # load()
    url = "http://127.0.0.1:{}/".format(port)
    logging.info("Starting browser at {}".format(url))
    # webbrowser.open_new(url)

    threading.Timer(1.25, lambda: webbrowser.open(url) ).start()

    app.run(
        port=port#,
        # debug=True
    ) 
Example #2
Source File: commands.py    From earthengine with MIT License 6 votes vote down vote up
def run(self, unused_args, unused_config):
    """Generates and opens a URL to get auth code, then retrieve a token."""

    auth_url = ee.oauth.get_authorization_url()
    webbrowser.open_new(auth_url)

    print("""
    Opening web browser to address %s
    Please authorize access to your Earth Engine account, and paste
    the resulting code below.
    If the web browser does not start, please manually browse the URL above.
          """ % auth_url)

    auth_code = input('Please enter authorization code: ').strip()

    token = ee.oauth.request_token(auth_code)
    ee.oauth.write_token(token)
    print('\nSuccessfully saved authorization token.') 
Example #3
Source File: response.py    From pledgeservice with Apache License 2.0 6 votes vote down vote up
def showbrowser(self):
        """
        Show this response in a browser window (for debugging purposes,
        when it's hard to read the HTML).
        """
        import webbrowser
        import tempfile
        f = tempfile.NamedTemporaryFile(prefix='webtest-page',
                                        suffix='.html')
        name = f.name
        f.close()
        f = open(name, 'w')
        if PY3:
            f.write(self.body.decode(self.charset or 'ascii', 'replace'))
        else:
            f.write(self.body)
        f.close()
        if name[0] != '/':  # pragma: no cover
            # windows ...
            url = 'file:///' + name
        else:
            url = 'file://' + name
        webbrowser.open_new(url) 
Example #4
Source File: run_test.py    From aswan with GNU Lesser General Public License v2.1 6 votes vote down vote up
def coverage_html():
    """ 将coverage结果放置到html中并自动打开浏览器 """
    output_dir = os.path.join(os.getcwd(), 'coverage_output')
    if os.path.exists(output_dir):
        shutil.rmtree(output_dir)
    os.mkdir(output_dir)

    now_str = time.strftime("%Y%m%d%H%M")
    html_result_path = os.path.join(output_dir, now_str)
    html_cmd = 'coverage html -d {path}'.format(path=html_result_path)
    for test_file_path in find_test_file_paths():
        coverage_cmd = "coverage run -a --source=risk_models,builtin_funcs {path}".format(
            path=test_file_path)
        os.system(coverage_cmd)
    os.system(html_cmd)
    os.remove(os.path.join(os.getcwd(), '.coverage'))
    webbrowser.open_new(
        'file:///{base_dir}/index.html'.format(base_dir=html_result_path)) 
Example #5
Source File: UpdateInfoView.py    From moviecatcher with MIT License 6 votes vote down vote up
def updateInfo (self) :
		if self.udInfo != [] :
			if self.udInfo['version'] != '' :
				version = str(self.udInfo['version'])
			else :
				version = str(self.app['ver']) + ' Build (' + str(self.app['build']) + ')'
			verlabel = tkinter.Label(self.frame, text = 'Version : ' + version, fg = '#ddd', bg="#444", font = ("Helvetica", "10"), anchor = 'center')
			verlabel.grid(row = 1, column = 1)

			self.information = tkinter.Text(self.frame, height = 8, width = 35, bd = 0, fg = '#ddd', bg="#222", highlightthickness = 1, highlightcolor="#111", highlightbackground = '#111', selectbackground = '#116cd6', font = ("Helvetica", "12"))
			self.information.grid(row = 2, column = 1, pady = 10)
			self.information.delete('0.0', 'end')
			self.information.insert('end', self.udInfo['msg'])

			btn = tkinter.Button(self.frame, text = 'Download', width = 10, fg = '#222', highlightbackground = '#444', command = lambda target = self.udInfo['dUrl'] : webbrowser.open_new(target))
			btn.grid(row = 3, column = 1)
		else :
			self.timer = self.frame.after(50, self.updateInfo) 
Example #6
Source File: PlayerView.py    From moviecatcher with MIT License 6 votes vote down vote up
def showDlLink (self, link) :
		window = tkinter.Toplevel()
		window.title('下载链接')
		window.resizable(width = 'false', height = 'false')
		if self.Tools.isWin() :
			window.iconbitmap(self.Tools.getRes('biticon.ico'))

		topZone = tkinter.Frame(window, bd = 0, bg="#444")
		topZone.pack(expand = True, fill = 'both')

		textZone = tkinter.Text(topZone, height = 8, width = 50, bd = 10, bg="#444", fg = '#ddd', highlightthickness = 0, selectbackground = '#116cd6')
		textZone.grid(row = 0, column = 0, sticky = '')
		textZone.insert('insert', link)

		dlBtn = tkinter.Button(topZone, text = '下载', width = 10, fg = '#222', highlightbackground = '#444', command =  lambda url = link : webbrowser.open_new(url))
		dlBtn.grid(row = 1, column = 0, pady = 5) 
Example #7
Source File: commands.py    From aqua-monitor with GNU Lesser General Public License v3.0 6 votes vote down vote up
def run(self, unused_args, unused_config):
    """Generates and opens a URL to get auth code, then retrieve a token."""

    auth_url = ee.oauth.get_authorization_url()
    webbrowser.open_new(auth_url)

    print("""
    Opening web browser to address %s
    Please authorize access to your Earth Engine account, and paste
    the resulting code below.
    If the web browser does not start, please manually browse the URL above.
          """ % auth_url)

    auth_code = input('Please enter authorization code: ').strip()

    token = ee.oauth.request_token(auth_code)
    ee.oauth.write_token(token)
    print('\nSuccessfully saved authorization token.') 
Example #8
Source File: eurekatrees.py    From EurekaTrees with MIT License 6 votes vote down vote up
def main():
    parser = argparse.ArgumentParser(description='Parse a random forest')
    parser.add_argument('--trees', dest='trees', help='Path to file holding the trees.', required=True)
    parser.add_argument('--columns', dest='columns', default=None,
                        help='Path to csv file holding column index and column name.')
    parser.add_argument('--output_path', dest='output_path', default='.',
                        help='Path to outputted files.')
    args = parser.parse_args()
    column_name_dict = {}
    if args.columns:
        column_name_dict = read_columns(args.columns)
    trees = read_trees(args.trees)
    tree_list = []
    for index, tree in enumerate(trees):
        tree_obj = Tree()
        tree_obj.create_tree(tree, column_name_dict)
        js_struct = tree_obj.get_js_struct(tree_obj.root)
        node_dict = {'tree': [js_struct], 'max_depth': tree_obj.max_depth, 'max_breadth': tree_obj.max_breadth}
        tree_list.append(node_dict)
    make_tree_viz(tree_list, args.output_path)
    webbrowser.open_new(os.path.join(args.output_path, 'home.html')) 
Example #9
Source File: wiki.py    From azure-devops-cli-extension with MIT License 6 votes vote down vote up
def get_page(wiki, path, version=None, open=False,  # pylint: disable=redefined-builtin
             include_content=False, organization=None, project=None, detect=None):
    """Get the content of a page or open a page.
    :param wiki: Name or Id of the wiki.
    :type wiki: str
    :param path: Path of the wiki page.
    :type path: str
    :param version: Version (ETag) of the wiki page.
    :type version: str
    :param include_content: Include content of the page.
    :type include_content: str
    :param open: Open the wiki page in your web browser.
    :type open: bool
    """
    organization, project = resolve_instance_and_project(detect=detect,
                                                         organization=organization,
                                                         project=project)
    wiki_client = get_wiki_client(organization)
    page_object = wiki_client.get_page(
        wiki_identifier=wiki, project=project, path=path,
        recursion_level=None, version_descriptor=version,
        include_content=include_content)
    if open:
        webbrowser.open_new(url=page_object.page.remote_url)
    return page_object 
Example #10
Source File: webrecorder_full.py    From conifer with Apache License 2.0 6 votes vote down vote up
def __init__(self, argres):
        self.root_dir = argres.root_dir
        self.redis_dir = os.path.join(self.root_dir, 'redis')

        self.user_manager = None

        self.browser_redis = None

        self.default_user = argres.default_user

        self.browser_id = base64.b32encode(os.urandom(15)).decode('utf-8')

        self.dat_share_port = argres.dat_share_port
        self.behaviors_tarfile = argres.behaviors_tarfile

        super(WebrecorderRunner, self).__init__(argres, rec_port=0)

        if not argres.no_browser:
            import webbrowser
            webbrowser.open_new(os.environ['APP_HOST'] + '/') 
Example #11
Source File: guiClass.py    From Video-Downloader with GNU General Public License v2.0 6 votes vote down vote up
def __menu (self) :
		menubar = Tkinter.Menu(self.master)

		fileMenu = Tkinter.Menu(menubar, tearoff = 0)
		fileMenu.add_command(label = "Config", command = self.__configPanel)
		fileMenu.add_command(label = "Close", command = self.master.quit)
		menubar.add_cascade(label = "File", menu = fileMenu)

		aboutMenu = Tkinter.Menu(menubar, tearoff = 0)
		aboutMenu.add_command(label = "Info", command = self.__showInfo)
		aboutMenu.add_command(label = "Check Update", command = self.__chkUpdate)
		menubar.add_cascade(label = "About", menu = aboutMenu)

		helpMenu = Tkinter.Menu(menubar, tearoff = 0)
		helpMenu.add_command(label = "GitHub", command = lambda target = self.gitUrl : webbrowser.open_new(target))
		helpMenu.add_command(label = "Release Notes", command = lambda target = self.appUrl : webbrowser.open_new(target))
		helpMenu.add_command(label = "Send Feedback", command = lambda target = self.feedUrl : webbrowser.open_new(target))
		menubar.add_cascade(label = "Help", menu = helpMenu)

		self.master.config(menu = menubar) 
Example #12
Source File: sites.py    From DriveIt with Do What The F*ck You Want To Public License 5 votes vote down vote up
def get_image_link(self, parent_link, page):
        javascript_script = ''
        while javascript_script is '':
            javascript_script = self.get_data(self.general_formula % (parent_link, parent_link[2:-1], page),
                                              'http://www.dm5.com%s' % parent_link)
            if javascript_script is '':
                webbrowser.open_new('http://www.dm5.com%s' % parent_link)
                time.sleep(3)
        link = execjs.eval(javascript_script)[0]
        link_safe = self.unicodeToURL(link)
        return link_safe 
Example #13
Source File: sequencer.py    From leaguedirector with Apache License 2.0 5 votes vote down vote up
def openBlendHelp(self):
        threading.Thread(target=lambda: webbrowser.open_new('https://easings.net')).start() 
Example #14
Source File: server.py    From xcessiv with Apache License 2.0 5 votes vote down vote up
def launch(app):
    http_server = WSGIServer(('', app.config['XCESSIV_PORT']), app)
    webbrowser.open_new('http://localhost:' + str(app.config['XCESSIV_PORT']))
    http_server.serve_forever() 
Example #15
Source File: fixture.py    From mishkal with GNU General Public License v3.0 5 votes vote down vote up
def showbrowser(self):
        """
        Show this response in a browser window (for debugging purposes,
        when it's hard to read the HTML).
        """
        import webbrowser
        fn = tempnam_no_warning(None, 'paste-fixture') + '.html'
        f = open(fn, 'wb')
        f.write(self.body)
        f.close()
        url = 'file:' + fn.replace(os.sep, '/')
        webbrowser.open_new(url) 
Example #16
Source File: PySourceColor.py    From mishkal with GNU General Public License v3.0 5 votes vote down vote up
def showpage(path):
    """Helper function to open webpages"""
    try:
        import webbrowser
        webbrowser.open_new(os.path.abspath(path))
    except:
        traceback.print_exc() 
Example #17
Source File: main.py    From seu-jwc-catcher with MIT License 5 votes vote down vote up
def click_about(text):
    print("You clicked '%s'" % text)
    webbrowser.open_new(text) 
Example #18
Source File: main.py    From seu-jwc-catcher with MIT License 5 votes vote down vote up
def check_table():
    global username
    dialog = Toplevel(root)
    dialog.geometry('240x100+360+300')
    dialog.title('请输入学期')
    Label(dialog, text="例如,在下面的输入框中输入:16-17-2").pack()
    v = StringVar()
    Entry(dialog,textvariable=v).pack(pady=5)
    Button(dialog, text=' 查看课表 ', command=lambda: webbrowser.open_new(r"http://xk.urp.seu.edu.cn/jw_s"
                                                                      r"ervice/service/stuCurriculum.action?queryStudentId=" + str(
        username) + "&queryAcademicYear=" + v.get())).pack(pady=5) 
Example #19
Source File: pmca-gui.py    From Sony-PMCA-RE with MIT License 5 votes vote down vote up
def __init__(self, parent, **kwargs):
  UiFrame.__init__(self, parent, **kwargs)

  self.modeVar = IntVar(value=self.MODE_APP)

  appFrame = Labelframe(self, padding=5)
  appFrame['labelwidget'] = Radiobutton(appFrame, text='Select an app from the app list', variable=self.modeVar, value=self.MODE_APP)
  appFrame.columnconfigure(0, weight=1)
  appFrame.pack(fill=X)

  self.appCombo = Combobox(appFrame, state='readonly')
  self.appCombo.bind('<<ComboboxSelected>>', lambda e: self.modeVar.set(self.MODE_APP))
  self.appCombo.grid(row=0, column=0, sticky=W+E)
  self.setAppList([])

  self.appLoadButton = Button(appFrame, text='Refresh', command=AppLoadTask(self).run)
  self.appLoadButton.grid(row=0, column=1)

  appListLink = Label(appFrame, text='Source', foreground='blue', cursor='hand2')
  appListLink.bind('<Button-1>', lambda e: webbrowser.open_new('https://' + config.appengineServer + '/apps'))
  appListLink.grid(columnspan=2, sticky=W)

  apkFrame = Labelframe(self, padding=5)
  apkFrame['labelwidget'] = Radiobutton(apkFrame, text='Select an apk', variable=self.modeVar, value=self.MODE_APK)
  apkFrame.columnconfigure(0, weight=1)
  apkFrame.pack(fill=X)

  self.apkFile = Entry(apkFrame)
  self.apkFile.grid(row=0, column=0, sticky=W+E)

  self.apkSelectButton = Button(apkFrame, text='Open apk...', command=self.openApk)
  self.apkSelectButton.grid(row=0, column=1)

  self.installButton = Button(self, text='Install selected app', command=InstallTask(self).run, padding=5)
  self.installButton.pack(fill=X, pady=(5, 0))

  self.run(AppLoadTask(self).run) 
Example #20
Source File: Question.py    From zhihu-terminal with MIT License 5 votes vote down vote up
def open_in_browser(self):
        webbrowser.open_new(self.url) 
Example #21
Source File: Answer.py    From zhihu-terminal with MIT License 5 votes vote down vote up
def open_in_browser(self):
        webbrowser.open_new(self.url) 
Example #22
Source File: Zhuanlan.py    From zhihu-terminal with MIT License 5 votes vote down vote up
def open_in_browser(self):
        webbrowser.open_new(self.originalurl) 
Example #23
Source File: User.py    From zhihu-terminal with MIT License 5 votes vote down vote up
def open_in_browser(self):
        webbrowser.open_new(self.url) 
Example #24
Source File: User.py    From zhihu-terminal with MIT License 5 votes vote down vote up
def open_weibo(self):
        weibo = self.get_weibo()
        if weibo:
            webbrowser.open_new(weibo)
        else:
            print termcolor.colored("该用户没有绑定微博", "magenta") 
Example #25
Source File: personality.py    From Jarvis with MIT License 5 votes vote down vote up
def open_analysis(self):
        url = "https://www.16personalities.com/{}-personality"
        webbrowser.open_new(url.format(self.type.lower())) 
Example #26
Source File: search.py    From Jarvis with MIT License 5 votes vote down vote up
def open_browser(self):
        if self.new_tab is False:
            # Opens search results in a new browser window.
            webbrowser.open_new(self.link)
        else:
            # Opens search results in a new tab.
            webbrowser.open_new_tab(self.link) 
Example #27
Source File: gulp.py    From sublime-gulp with MIT License 5 votes vote down vote up
def open_in_browser(self, index=-1):
        if index >= 0 and index < self.plugins.length:
            webbrowser.open_new(self.plugins.get(index).get('homepage')) 
Example #28
Source File: mac_tray.py    From oss-ftp with MIT License 5 votes vote down vote up
def config_(self, notification):
        webbrowser.open_new("http://127.0.0.1:8192/")

    #Note: the function name for action can include '_'
    # limited by Mac cocoa 
Example #29
Source File: gtk_tray.py    From oss-ftp with MIT License 5 votes vote down vote up
def show_control_web(self, widget=None, data=None):
        webbrowser.open_new("http://127.0.0.1:8192/") 
Example #30
Source File: GUI.py    From nekros with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def retrive_key(self):
        attacker_url = self.retrive_key_url
        webbrowser.open_new(attacker_url)