本文整理汇总了Python中src.util.workflow函数的典型用法代码示例。如果您正苦于以下问题:Python workflow函数的具体用法?Python workflow怎么用?Python workflow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了workflow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: menu
def menu(self, args):
workflow().add_item(
"Search for projects",
"Search for projects and open the project page in your default browser",
autocomplete=":projects ",
icon=icons.PROJECTS,
)
workflow().add_item(
"Search for repositories",
"Search for repositories and open the repository page in your default browser",
autocomplete=":repos ",
icon=icons.REPOSITORIES,
)
workflow().add_item(
"Search or raise pull requests",
"Search for pull requests or raise new ones based on Stash's suggestions",
autocomplete=":pullrequests ",
icon=icons.PULL_REQUESTS,
)
workflow().add_item(
"Preferences",
"Change Stash connection settings, refresh the cache or the workflow itself",
autocomplete=":config ",
icon=icons.SETTINGS,
)
workflow().add_item(
"Help", "Get help about the workflow and how to get support", autocomplete=":help ", icon=icons.HELP
)
示例2: _add_to_result_list
def _add_to_result_list(self, project):
workflow().add_item(title=project.name,
subtitle=project.description,
arg=':projects {}'.format(project.key),
valid=True,
largetext=project.name,
icon=workflow().cachefile('{}/{}'.format(PROJECT_AVATAR_DIR, project.key)))
示例3: menu
def menu(self, args):
workflow().add_item(
'Search for projects',
'Search for projects and open the project page in your default browser',
autocomplete=':projects ',
icon=icons.PROJECTS
)
workflow().add_item(
'Search for repositories',
'Search for repositories and open the repository page in your default browser',
autocomplete=':repos ',
icon=icons.REPOSITORIES
)
workflow().add_item(
'Search for pull requests',
'Search for pull requests and open them in your default browser',
autocomplete=':pullrequests ',
icon=icons.PULL_REQUESTS
)
workflow().add_item(
'Preferences',
'Change Stash connection settings, refresh the cache or the workflow itself',
autocomplete=':config ',
icon=icons.SETTINGS
)
workflow().add_item(
'Help',
'Get help about the workflow and how to get support',
autocomplete=':help ',
icon=icons.HELP
)
示例4: menu
def menu(self, args):
if len(args) == 2:
workflow().add_item(
u"Suggested pull requests {}".format(_num_pull_requests("suggestions")),
"Suggested pull requests to raise based on your recent commits",
arg=":pullrequests suggestions",
icon=icons.PR_SUGGESTIONS,
valid=True,
)
workflow().add_item(
u"All open pull requests {}".format(_num_pull_requests("open")),
"Search in all open pull requests",
arg=":pullrequests open",
icon=icons.OPEN,
valid=True,
)
workflow().add_item(
u"Your pull requests to review {}".format(_num_pull_requests("review")),
"Search in pull requests you have to review",
arg=":pullrequests review",
icon=icons.REVIEW,
valid=True,
)
workflow().add_item(
u"Your created pull requests {}".format(_num_pull_requests("created")),
"Search in pull requests you created",
arg=":pullrequests created",
icon=icons.CREATED,
valid=True,
)
workflow().add_item("Main menu", autocomplete="", icon=icons.GO_BACK)
else:
cache_key, update_interval = _pull_request_modes[args[-2]]
pull_request_menu = PullRequestFilterableMenu(args, update_interval, cache_key)
return pull_request_menu.run()
示例5: _add_to_result_list
def _add_to_result_list(self, pull_request):
workflow().add_item(title=u'{} #{}: {} → {}'.format(pull_request.repo_name, pull_request.pull_request_id,
pull_request.from_branch, pull_request.to_branch),
subtitle=pull_request.title,
arg=':pullrequests ' + pull_request.link,
largetext=pull_request.title,
valid=True,
icon=workflow().cachefile('{}/{}'.format(PROJECT_AVATAR_DIR, pull_request.project_key)))
示例6: _notify_if_upgrade_available
def _notify_if_upgrade_available():
if workflow().update_available:
new_version = workflow().cached_data('__workflow_update_status', max_age=0)['version']
workflow().add_item('An update is available!',
'Update the workflow from version {} to {}'.format(__version__, new_version),
arg=':config update',
valid=True,
icon=icons.UPDATE)
示例7: _add_to_result_list
def _add_to_result_list(self, plan):
workflow().add_item(title=u'{} {}'.format(plan.name, FAVOURITE_PLAN if plan.is_favourite else ''),
subtitle=plan.description,
largetext=plan.name,
arg=':plans ' + plan.plan_key,
modifier_subtitles={u'shift': u'Trigger build execution for this plan'},
# `cmd``, ``ctrl``, ``shift``, ``alt`` and ``fn``
copytext='{}/browse/{}'.format(workflow().settings.get(HOST_URL), plan.plan_key),
valid=True)
示例8: _add_to_result_list
def _add_to_result_list(self, pull_request):
workflow().add_item(
title=unicode(pull_request),
subtitle=pull_request.title,
arg=":pullrequests " + pull_request.link,
largetext=pull_request.title,
valid=True,
icon=workflow().cachefile("{}/{}".format(PROJECT_AVATAR_DIR, pull_request.project_key)),
)
示例9: _add_to_result_list
def _add_to_result_list(self, repo):
workflow().add_item(title=u'{} / {} {} {}'.format(repo.project_name,
repo.name,
PUBLIC if repo.public else '',
FORK if repo.fork else ''),
arg=':repos {}/{}'.format(repo.project_key, repo.slug),
valid=True,
largetext=repo.name,
copytext=repo.clone_url, # allows to use CMD+C to copy the clone URL
icon=workflow().cachefile('{}/{}'.format(PROJECT_AVATAR_DIR, repo.project_key)))
示例10: _add_to_result_list
def _add_to_result_list(self, branch):
workflow().add_item(title=branch.name,
subtitle=branch.description,
largetext=branch.name,
arg=':branches ' + branch.key,
modifier_subtitles={
u'shift': u'Trigger build execution for this plan branch'
}, # `cmd``, ``ctrl``, ``shift``, ``alt`` and ``fn``
copytext='{}/browse/{}'.format(workflow().settings.get(HOST_URL), branch.key),
valid=True)
示例11: execute
def execute(self, args, ctrl_pressed, shift_pressed):
if 'sethost' in args:
workflow().settings[HOST_URL] = args[-1]
print('New Bamboo host: {}'.format(args[-1]))
elif 'setuser' in args:
workflow().settings[USER_NAME] = args[-1]
print('New Bamboo user: {}'.format(args[-1]))
elif 'setpw' in args:
workflow().save_password(USER_PW, args[-1])
print('Saved Bamboo password in keychain')
elif 'verifycert' in args:
verify_cert = workflow().settings.get(VERIFY_CERT, 'false') == 'true'
toggle = (str(not verify_cert)).lower()
workflow().settings[VERIFY_CERT] = toggle
print('Enabled certificate verification' if toggle == 'true' else 'Disabled certificate verification')
elif 'sync' in args:
workflow().clear_cache()
update_bamboo_cache()
print('Bamboo data synchronization triggered')
elif 'update' in args:
try:
if workflow().start_update():
print('Update of workflow finished')
else:
print('You already have the latest workflow version')
except Exception, e:
print('Update of workflow failed: {}'.format(str(e)))
示例12: _fetch_bamboo_data_if_necessary
def _fetch_bamboo_data_if_necessary(bamboo_facade):
# cached_data can only take a bare callable (no args),
# so we need to wrap callables needing arguments in a function
# that needs none.
def wrapper_projects():
return bamboo_facade.projects()
projects = workflow().cached_data(PROJECTS_CACHE_KEY, wrapper_projects, max_age=UPDATE_INTERVAL_PROJECTS)
workflow().logger.debug('{} projects cached'.format(len(projects)))
def wrapper_plans():
plans_with_branches = bamboo_facade.plans()
for plan in plans_with_branches:
branches = bamboo_facade.branches(plan.plan_key)
plan.branches = branches
return plans_with_branches
plans = workflow().cached_data(PLANS_CACHE_KEY, wrapper_plans, max_age=UPDATE_INTERVAL_PLANS)
workflow().logger.debug('{} plans cached'.format(len(plans)))
def wrapper_results():
return bamboo_facade.results()
results = workflow().cached_data(STATUS_CACHE_KEY, wrapper_results, max_age=UPDATE_INTERVAL_STATUS)
workflow().logger.debug('{} build results cached'.format(len(results)))
示例13: build_bamboo_facade
def build_bamboo_facade():
bamboo_host = workflow().settings.get(HOST_URL, None)
if not bamboo_host:
raise ValueError("Bamboo host URL not set.")
bamboo_user = workflow().settings.get(USER_NAME, None)
try:
bamboo_pw = workflow().get_password(USER_PW)
except PasswordNotFound:
bamboo_pw = None
verify_cert = workflow().settings.get(VERIFY_CERT, "false") == "true"
return BambooFacade(bamboo_host, bamboo_user, bamboo_pw, verify_cert)
示例14: build_stash_facade
def build_stash_facade():
stash_host = workflow().settings.get(HOST_URL, None)
if stash_host is None:
raise ValueError("Stash host URL not set.")
stash_user = workflow().settings.get(USER_NAME, None)
try:
stash_pw = workflow().get_password(USER_PW)
except PasswordNotFound:
stash_pw = None
verify_cert = workflow().settings.get(VERIFY_CERT, "false") == "true"
return StashFacade(stash_host, stash_user, stash_pw, verify_cert)
示例15: menu
def menu(self, args):
if len(args) == 2:
workflow().add_item(
u'All open pull requests {}'.format(_num_pull_requests('open')),
'Search in all open pull requests',
arg=':pullrequests open',
icon=icons.OPEN,
valid=True
)
workflow().add_item(
u'Your pull requests to review {}'.format(_num_pull_requests('review')),
'Search in pull requests you have to review',
arg=':pullrequests review',
icon=icons.REVIEW,
valid=True
)
workflow().add_item(
u'Your created pull requests {}'.format(_num_pull_requests('created')),
'Search in pull requests you created',
arg=':pullrequests created',
icon=icons.CREATED,
valid=True
)
workflow().add_item(
'Main menu',
autocomplete='', icon=icons.GO_BACK
)
else:
cache_key, update_interval = _pull_request_modes[args[-2]]
pull_request_menu = PullRequestFilterableMenu(args, update_interval, cache_key)
return pull_request_menu.run()