def openGameReport(self):
selected = self.get_selectedMatches()
if selected:
for match in selected:
webbrowser.open_new_tab('https://www.fupa.net/spielberichte/xxx-xxx-xxx-%d.html' % match['match_id'])
python类open_new_tab()的实例源码
def oauth_dance(redis_client, conf, bottle_app, file_event_handler, bottle_thread=None):
diycrate_secret_key = redis_client.get('diycrate_secret_key') or str(uuid.uuid4())
if not redis_client.exists('diycrate_secret_key'):
redis_client.set('diycrate_secret_key', diycrate_secret_key)
bottle_app.oauth = file_event_handler.oauth = setup_remote_oauth(redis_client)
import requests
auth_url, bottle_app.csrf_token = requests.get(conf['box']['authorization_url'], data={'redirect_url': 'https://localhost:8080/', }, verify=False).json()
# auth_url, bottle_app.csrf_token = bottle_app.oauth.get_authorization_url(auth_url)
if bottle_thread and not bottle_thread.is_alive():
bottle_thread.start()
webbrowser.open_new_tab(auth_url) # make it easy for the end-user to start auth
def main():
build_project_path = '_build'
if not os.path.exists(build_project_path):
os.system('make html')
server = Server()
server.watch('./*.rst', shell('make html'))
server.watch('./*/*.rst', shell('make html'))
webbrowser.open_new_tab('http://127.0.0.1:5500')
server.serve(root='_build/html')
def watch(game, show, template, in_window, use_streamlink, quality, just_print):
matches = list(download_matches(game))
if not show:
matches = [m for m in matches if m.get('stream')]
if not matches:
click.echo('No streams found :(')
return
template = template if template else DEFAULT_TEMPLATE_ALL if game == 'all' else DEFAULT_TEMPLATE
template = Template(template)
items = ['{}: {}'.format(i, template.render(m)) for i, m in enumerate(matches)]
for item in items:
click.echo(item)
click.echo('-' * len(sorted(items)[0]))
while True:
click.echo('select stream to show: ', nl=False)
choice = input('')
if not choice.isdigit():
click.echo(' "{}" is not a number'.format(choice))
continue
choice = int(choice)
if choice not in range(0, len(matches)):
click.echo(' {} is out of range'.format(choice))
continue
break
selected = matches[choice].get('stream')
if not selected:
click.secho('cannot stream for match #{}: no stream'.format(choice), err=True, fg='red')
return
if just_print:
click.echo(selected)
return
click.echo('Opening {}...'.format(selected))
if use_streamlink:
subprocess.Popen(['nohup streamlink "{}" {} &'.format(selected, quality)], shell=True, start_new_session=True)
elif not in_window:
webbrowser.open_new_tab(selected)
else:
webbrowser.open(selected, new=1)
def openURL(self, url):
self.log.debug("Open URL %s" % url)
webbrowser.open_new_tab(url)
self.loop.screen.clear()
def run(self, online=False):
if online:
webbrowser.open_new_tab('http://requester.org')
return
show_read_only_doc_view(self.window.new_file(),
sublime.load_resource('Packages/Requester/docs/_content/body.md'),
'Requester Documentation')
def run(self):
webbrowser.open_new_tab('http://docs.python-requests.org/en/master/user/quickstart/')
def open_in_browser(self):
webbrowser.open_new_tab(str(self))
def run(self):
webbrowser.open_new_tab("https://github.com/notifications")
def get_update(self):
url = DOWNLOAD_PAGE
if self.update:
latest = '/tag/v{}'.format(self.newversion)
url = url + latest
webbrowser.open_new_tab(url)
def get_update(self):
url = DOWNLOAD_PAGE
if self.update:
latest = '/tag/v{}'.format(self.newversion)
url = url + latest
webbrowser.open_new_tab(url)
def execute(self, context):
webbrowser.open_new_tab(url)
return {'FINISHED'}
def open_in_default_browser(url):
browser_map = setting.get_default_browser()
browser_name = browser_map['name']
browser_path = browser_map['path']
if not browser_path or not os.path.exists(browser_path) or browser_name == "default":
webbrowser.open_new_tab(url)
elif browser_map['name'] == "chrome-private":
# chromex = "\"%s\" --incognito %s" % (browser_path, url)
# os.system(chromex)
browser = webbrowser.get('"' + browser_path +'" --incognito %s')
browser.open(url)
# os.system("\"%s\" -ArgumentList @('-incognito', %s)" % (browser_path, url))
else:
try:
webbrowser.register('chromex', None, webbrowser.BackgroundBrowser(browser_path))
webbrowser.get('chromex').open_new_tab(url)
except Exception as e:
webbrowser.open_new_tab(url)
##########################################################################################
#END
##########################################################################################
def on_navigate(self, href):
""" open the link in a new tab on web browser """
try:
webbrowser.open_new_tab(href)
except Exception as e:
logging.error('cannot open link on web browser.')
def on_navigate(self, url):
if url.startswith('http://') or url.startswith('https://'):
webbrowser.open_new_tab(url)
else:
self.window.open_file(url)
def _default_show_url(url):
import webbrowser
webbrowser.open_new_tab(url)
def show_wiki(self, widget):
webbrowser.open_new_tab('http://inguma.eu/projects/bokken/wiki')
def on_link_clicked(self, link, _=None):
"""Event for clicked link."""
webbrowser.open_new_tab(self.preferences["urls"][link.get_name()])
def run_upgrade(args):
api_client = ApiClient()
client = AdminApi(api_client)
account = call_api(lambda: client.get_account_info())
if account.key is None:
print('You have not registered with an account. '
'Please run ' + bold('riseml account register'))
else:
register_url = get_riseml_url() + 'upgrade/%s' % account.key
if browser_available():
webbrowser.open_new_tab(register_url)
else:
print('Please visit this URL and follow instructions'
' to upgrade your account: %s' % register_url)
def openurl(url):
webbrowser.open_new_tab(url)