本文整理匯總了Python中click.launch方法的典型用法代碼示例。如果您正苦於以下問題:Python click.launch方法的具體用法?Python click.launch怎麽用?Python click.launch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類click
的用法示例。
在下文中一共展示了click.launch方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: select
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def select(questions, num):
print_full_question(questions[num - 1])
working = True
while working:
user_input = click.prompt("Enter b to launch browser, x to return to search, or q to quit")
if user_input == 'b':
click.launch(questions[num - 1].json['link'])
elif user_input == 'q':
sys.exit()
elif user_input == 'x':
click.echo("\n" * 12)
# Ranging over the 5 questions including the user's choice
origin = 0
if not num % NUM_RESULTS:
origin = num - NUM_RESULTS
else:
origin = num - num % NUM_RESULTS
for j in range(origin, origin + NUM_RESULTS):
print_question(questions[j], j + 1)
working = False
else:
click.echo(click.style(
"The input entered was not recognized as a valid choice.",
fg="red",
err=True))
示例2: dashboard
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def dashboard(ctx, yes, url):
"""Open this operation's dashboard details in browser."""
owner, project_name, run_uuid = get_project_run_or_local(
ctx.obj.get("project"), ctx.obj.get("run_uuid"), is_cli=True,
)
dashboard_url = clean_host(settings.CLIENT_CONFIG.host)
run_url = "{}/{}/{}/runs/{}/".format(dashboard_url, owner, project_name, run_uuid)
if url:
Printer.print_header("The dashboard is available at: {}".format(run_url))
sys.exit(0)
if not yes:
click.confirm(
"Dashboard page will now open in your browser. Continue?",
abort=True,
default=True,
)
click.launch(run_url)
示例3: publish_via_kokoro
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def publish_via_kokoro(ctx: TagContext) -> None:
kokoro_url = "https://fusion.corp.google.com/projectanalysis/current/KOKORO/"
ctx.fusion_url = parse.urljoin(
kokoro_url, parse.quote_plus(f"prod:{ctx.kokoro_job_name}")
)
if ctx.interactive:
pyperclip.copy(ctx.release_tag)
click.secho(
"> Trigger the Kokoro build with the commitish below to publish to PyPI. The commitish has been copied to the clipboard.",
fg="cyan",
)
click.secho(f"Kokoro build URL:\t\t{click.style(ctx.fusion_url, underline=True)}")
click.secho(f"Commitish:\t{click.style(ctx.release_tag, bold=True)}")
if ctx.interactive:
if click.confirm("Would you like to go the Kokoro build page?", default=True):
click.launch(ctx.fusion_url)
示例4: open
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def open(alias):
"""Open the series URL in a browser."""
s = db.Series.alias_lookup(alias)
click.launch(s.url)
示例5: launch
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def launch():
"""Launch applicaiton."""
click.launch("https://click.palletsprojects.com/")
示例6: _process_open
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def _process_open(self):
"""Open link in a browser."""
click.launch(self._format_issue_url())
if not click.confirm('Did it work?', default=True):
click.echo()
self._process_print()
click.secho(
'\nOpen the line manually and copy the text above\n',
fg='yellow'
)
click.secho(
' ' + self.REPO_URL + self.ISSUE_SUFFIX + '\n', bold=True
)
示例7: dashboard
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def dashboard(namespace):
click.launch(dashboard_url(namespace))
示例8: read
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def read(ctx, item_id, with_note):
""" Read an item attachment. """
try:
item_id = pick_item(ctx.obj, item_id)
except ValueError as e:
ctx.fail(e.args[0])
read_att = None
attachments = ctx.obj.attachments(item_id)
if not attachments:
ctx.fail("Could not find an attachment for reading.")
elif len(attachments) > 1:
click.echo("Multiple attachments available.")
read_att = select([(att, att['data']['title'])
for att in attachments])
else:
read_att = attachments[0]
att_path = ctx.obj.get_attachment_path(read_att)
click.echo("Opening '{}'.".format(att_path))
click.launch(str(att_path), wait=False)
if with_note:
existing_notes = list(ctx.obj.notes(item_id))
if existing_notes:
edit_existing = click.confirm("Edit existing note?")
if edit_existing:
note = pick_note(ctx, ctx.obj, item_id)
else:
note = None
else:
note = None
note_body = click.edit(
text=note['data']['note']['text'] if note else None,
extension=get_extension(ctx.obj.note_format))
if note_body and note is None:
ctx.obj.create_note(item_id, note_body)
elif note_body:
note['data']['note']['text'] = note_body
ctx.obj.save_note(note)
示例9: create_api_key
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def create_api_key():
""" Interactively create a new API key via Zotero's OAuth API.
Requires the user to enter a verification key displayed in the browser.
:returns: API key and the user's library ID
"""
auth = OAuth1Service(
name='zotero',
consumer_key=CLIENT_KEY,
consumer_secret=CLIENT_SECRET,
request_token_url=REQUEST_TOKEN_URL,
access_token_url=ACCESS_TOKEN_URL,
authorize_url=AUTH_URL,
base_url=BASE_URL)
token, secret = auth.get_request_token(
params={'oauth_callback': 'oob'})
auth_url = auth.get_authorize_url(token)
auth_url += '&' + urlencode({
'name': 'zotero-cli',
'library_access': 1,
'notes_access': 1,
'write_access': 1,
'all_groups': 'read'})
click.echo("Opening {} in browser, please confirm.".format(auth_url))
click.launch(auth_url)
verification = click.prompt("Enter verification code")
token_resp = auth.get_raw_access_token(
token, secret, method='POST',
data={'oauth_verifier': verification})
if not token_resp:
logging.debug(token_resp.content)
click.fail("Error during API key generation.")
access = urlparse.parse_qs(token_resp.text)
return access['oauth_token'][0], access['userID'][0]
示例10: doc
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def doc(version):
if version not in ["dev", "0.12", "0.11", "0.10", "0.9"]:
version = "dev"
url = 'http://bottlepy.org/docs/{}/'.format(version)
click.launch(url)
click.echo(u'Bottle Boilerplate start browser!')
示例11: dashboard
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def dashboard(yes, url):
"""Open dashboard in browser."""
dashboard_url = "{}/app".format(PolyaxonClient().api_config.http_host)
if url:
click.echo(dashboard_url)
sys.exit(0)
if not yes:
click.confirm('Dashboard page will now open in your browser. Continue?',
abort=True, default=True)
click.launch(dashboard_url)
示例12: view
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def view(stmo, file_name):
"""Opens a query in a browser.
FILE_NAME: The filename of the tracked query SQL.
Opens a browser window to the redash query.
"""
try:
url = stmo.url_for_query(file_name)
except KeyError:
click.echo("Couldn't find a query ID for {}: No such query, "
"maybe you need to 'track' first".format(file_name),
err=True)
sys.exit(1)
click.launch(url)
示例13: dashboard
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def dashboard(yes, url):
"""Open dashboard in browser."""
dashboard_url = settings.CLIENT_CONFIG.host
if url:
click.echo(dashboard_url)
sys.exit(0)
if not yes:
click.confirm(
"Dashboard page will now open in your browser. Continue?",
abort=True,
default=True,
)
click.launch(dashboard_url)
示例14: dashboard
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def dashboard(ctx, yes, url):
"""Open this operation's dashboard details in browser."""
owner, project_name = get_project_or_local(ctx.obj.get("project"), is_cli=True)
dashboard_url = clean_host(settings.CLIENT_CONFIG.host)
project_url = "{}/{}/{}/".format(dashboard_url, owner, project_name)
if url:
Printer.print_header("The dashboard is available at: {}".format(project_url))
sys.exit(0)
if not yes:
click.confirm(
"Dashboard page will now open in your browser. Continue?",
abort=True,
default=True,
)
click.launch(project_url)
示例15: open_folder
# 需要導入模塊: import click [as 別名]
# 或者: from click import launch [as 別名]
def open_folder(self):
click.launch(environ.get_app_dir())