本文整理汇总了Python中webkitpy.common.system.user.User类的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _builder_to_analyze
def _builder_to_analyze(self):
statuses = self._tool.buildbot.builder_statuses()
choices = [status["name"] for status in statuses]
chosen_name = User.prompt_with_list("Which builder to analyze:", choices)
for status in statuses:
if status["name"] == chosen_name:
return (self._tool.buildbot.builder_with_name(chosen_name), status["built_revision"])
示例2: test_prompt_when_exceeded_repeats
def test_prompt_when_exceeded_repeats(self):
self.repeatsRemaining = 2
def mock_raw_input(message):
self.repeatsRemaining -= 1
return None
self.assertEqual(User.prompt("input", repeat=self.repeatsRemaining, raw_input=mock_raw_input), None)
示例3: create_bug
def create_bug(
self,
bug_title,
bug_description,
component=None,
diff=None,
patch_description=None,
cc=None,
blocked=None,
assignee=None,
mark_for_review=False,
mark_for_commit_queue=False,
):
self.authenticate()
_log.info('Creating bug with title "%s"' % bug_title)
self.browser.open(config_urls.bug_server_url + "enter_bug.cgi?product=WebKit")
self.browser.select_form(name="Create")
component_items = self.browser.find_control("component").items
component_names = map(lambda item: item.name, component_items)
if not component:
component = "New Bugs"
if component not in component_names:
component = User.prompt_with_list("Please pick a component:", component_names)
self.browser["component"] = [component]
if cc:
self.browser["cc"] = cc
if blocked:
self.browser["blocked"] = unicode(blocked)
if not assignee:
assignee = self.username
if assignee and not self.browser.find_control("assigned_to").disabled:
self.browser["assigned_to"] = assignee
self.browser["short_desc"] = bug_title
self.browser["comment"] = bug_description
if diff:
# _fill_attachment_form expects a file-like object
# Patch files are already binary, so no encoding needed.
assert isinstance(diff, str)
patch_file_object = StringIO.StringIO(diff)
commit_flag = CommitQueueFlag.mark_for_nothing
if mark_for_commit_queue:
commit_flag = CommitQueueFlag.mark_for_commit_queue
self._fill_attachment_form(
patch_description,
patch_file_object,
mark_for_review=mark_for_review,
commit_flag=commit_flag,
is_patch=True,
)
response = self.browser.submit()
bug_id = self._check_create_bug_response(response.read())
_log.info("Bug %s created." % bug_id)
_log.info("%sshow_bug.cgi?id=%s" % (config_urls.bug_server_url, bug_id))
return bug_id
示例4: test_prompt_repeat
def test_prompt_repeat(self):
self.repeatsRemaining = 2
def mock_raw_input(message):
self.repeatsRemaining -= 1
if not self.repeatsRemaining:
return UserTest.example_user_response
return None
self.assertEqual(User.prompt("input", repeat=self.repeatsRemaining, raw_input=mock_raw_input), UserTest.example_user_response)
示例5: read_credentials
def read_credentials(self):
username, password = self._credentials_from_environment()
# FIXME: We don't currently support pulling the username from one
# source and the password from a separate source.
if not username or not password:
username, password = self._credentials_from_git()
if not username or not password:
username, password = self._credentials_from_keychain(username)
if username and not password and self._keyring:
password = self._keyring.get_password(self.host, username)
if not username:
username = User.prompt("%s login: " % self.host)
if not password:
password = User.prompt_password("%s password for %s: " % (self.host, username))
self._offer_to_store_credentials_in_keyring(username, password)
return (username, password)
示例6: _builder_to_explain
def _builder_to_explain(self):
builder_statuses = self.tool.buildbot.builder_statuses()
red_statuses = [status for status in builder_statuses if not status["is_green"]]
print "%s failing" % (pluralize("builder", len(red_statuses)))
builder_choices = [status["name"] for status in red_statuses]
# We could offer an "All" choice here.
chosen_name = User.prompt_with_list("Which builder to diagnose:", builder_choices)
# FIXME: prompt_with_list should really take a set of objects and a set of names and then return the object.
for status in red_statuses:
if status["name"] == chosen_name:
return (self.tool.buildbot.builder_with_name(chosen_name), status["built_revision"])
示例7: commit_with_message
def commit_with_message(self, message, username=None):
if self.dryrun:
# Return a string which looks like a commit so that things which parse this output will succeed.
return "Dry run, no commit.\nCommitted revision 0."
svn_commit_args = ["svn", "commit"]
if not username and not self.has_authorization_for_realm():
username = User.prompt("%s login: " % self.svn_server_host, repeat=5)
if not username:
raise Exception("You need to specify the username on %s to perform the commit as." % self.svn_server_host)
if username:
svn_commit_args.extend(["--username", username])
svn_commit_args.extend(["-m", message])
# FIXME: Should this use cwd=self.checkout_root?
return run_command(svn_commit_args, error_handler=commit_error_handler)