本文整理汇总了Python中modules.logging.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: begin_work_queue
def begin_work_queue(self):
log("CAUTION: %s will discard all local changes in \"%s\"" % (self.name, self.tool.scm().checkout_root))
if self.options.confirm:
response = raw_input("Are you sure? Type \"yes\" to continue: ")
if (response != "yes"):
error("User declined.")
log("Running WebKit %s." % self.name)
示例2: fetch_attachments_from_bug
def fetch_attachments_from_bug(self, bug_id):
bug_url = self.bug_url_for_bug_id(bug_id, xml=True)
log("Fetching: " + bug_url)
page = urllib2.urlopen(bug_url)
soup = BeautifulSoup(page)
attachments = []
for element in soup.findAll("attachment"):
attachment = {}
attachment["bug_id"] = bug_id
attachment["is_obsolete"] = element.has_key("isobsolete") and element["isobsolete"] == "1"
attachment["is_patch"] = element.has_key("ispatch") and element["ispatch"] == "1"
attachment["id"] = str(element.find("attachid").string)
attachment["url"] = self.attachment_url_for_id(attachment["id"])
attachment["name"] = unicode(element.find("desc").string)
attachment["type"] = str(element.find("type").string)
review_flag = element.find("flag", attrs={"name": "review"})
if review_flag and review_flag["status"] == "+":
reviewer_email = review_flag["setter"]
# We could lookup the full email address instead once we update full_name_from_bugzilla_name
bugzilla_name = reviewer_email.split("@")[0]
attachment["reviewer"] = self.full_name_from_bugzilla_name(bugzilla_name)
attachments.append(attachment)
return attachments
示例3: authenticate
def authenticate(self):
if self.authenticated:
return
if self.dryrun:
log("Skipping log in for dry run...")
self.authenticated = True
return
(username, password) = read_credentials()
log("Logging in as %s..." % username)
self.browser.open(self.bug_server_url + "index.cgi?GoAheadAndLogIn=1")
self.browser.select_form(name="login")
self.browser["Bugzilla_login"] = username
self.browser["Bugzilla_password"] = password
response = self.browser.submit()
match = re.search("<title>(.+?)</title>", response.read())
# If the resulting page has a title, and it contains the word "invalid" assume it's the login failure page.
if match and re.search("Invalid", match.group(1), re.IGNORECASE):
# FIXME: We could add the ability to try again on failure.
error("Bugzilla login failed: %s" % match.group(1))
self.authenticated = True
示例4: credentials_from_keychain
def credentials_from_keychain(username=None):
if not is_mac_os_x():
return [username, None]
command = "/usr/bin/security %s -g -s %s" % ("find-internet-password", Bugzilla.bug_server_host)
if username:
command += " -a %s" % username
log('Reading Keychain for %s account and password. Click "Allow" to continue...' % Bugzilla.bug_server_host)
keychain_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
value = keychain_process.communicate()[0]
exit_code = keychain_process.wait()
if exit_code:
return [username, None]
match = re.search('^\s*"acct"<blob>="(?P<username>.+)"', value, re.MULTILINE)
if match:
username = match.group('username')
password = None
match = re.search('^password: "(?P<password>.+)"', value, re.MULTILINE)
if match:
password = match.group('password')
return [username, password]
示例5: ensure_clean_working_directory
def ensure_clean_working_directory(self, force):
if not force and not self.working_directory_is_clean():
print self.run_command(self.status_command(), raise_on_failure=False)
error("Working directory has modifications, pass --force-clean or --no-clean to continue.")
log("Cleaning working directory")
self.clean_working_directory()
示例6: create_bug_with_patch
def create_bug_with_patch(self, bug_title, bug_description, component, patch_file_object, patch_description, cc, mark_for_review=False):
self.authenticate()
log('Creating bug with patch description "%s"' % patch_description)
if self.dryrun:
log(bug_description)
return
self.browser.open(self.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 or component not in component_names:
component = self.prompt_for_component(component_names)
self.browser['component'] = [component]
if cc:
self.browser['cc'] = cc
self.browser['short_desc'] = bug_title
if bug_description:
log(bug_description)
self.browser['comment'] = bug_description
self.browser['description'] = patch_description
self.browser['ispatch'] = ("1",)
self.browser['flag_type-1'] = ('?',) if mark_for_review else ('X',)
self.browser.add_file(patch_file_object, "text/plain", "%s.patch" % timestamp(), 'data')
response = self.browser.submit()
bug_id = self._check_create_bug_response(response.read())
log("Bug %s created." % bug_id)
log("%sshow_bug.cgi?id=%s" % (self.bug_server_url, bug_id))
return bug_id
示例7: _fetch_list_of_patches_to_process
def _fetch_list_of_patches_to_process(self, options, args, tool):
all_patches = []
for bug_id in args:
patches = tool.bugs.fetch_reviewed_patches_from_bug(bug_id)
log("%s found on bug %s." % (pluralize("reviewed patch", len(patches)), bug_id))
all_patches += patches
return all_patches
示例8: run
def run(self):
self._begin_logging()
self._delegate.begin_work_queue()
while (self._delegate.should_continue_work_queue()):
try:
self._ensure_work_log_closed()
work_item = self._delegate.next_work_item()
if not work_item:
self._sleep("No work item.")
continue
if not self._delegate.should_proceed_with_work_item(work_item):
self._sleep("Not proceeding with work item.")
continue
# FIXME: Work logs should not depend on bug_id specificaly.
# This looks fixed, no?
self._open_work_log(work_item)
try:
self._delegate.process_work_item(work_item)
except ScriptError, e:
# Use a special exit code to indicate that the error was already
# handled in the child process and we should just keep looping.
if e.exit_code == self.handled_error_code:
continue
message = "Unexpected failure when landing patch! Please file a bug against bugzilla-tool.\n%s" % e.message_with_output()
self._delegate.handle_unexpected_error(work_item, message)
except KeyboardInterrupt, e:
log("\nUser terminated queue.")
return 1
except Exception, e:
traceback.print_exc()
# Don't try tell the status bot, in case telling it causes an exception.
self._sleep("Exception while preparing queue: %s." % e)
示例9: _run_security_tool
def _run_security_tool(self, username=None):
security_command = ["/usr/bin/security", "find-internet-password", "-g", "-s", self.host]
if username:
security_command += ["-a", username]
log('Reading Keychain for %s account and password. Click "Allow" to continue...' % self.host)
return self.executive.run_command(security_command)
示例10: ensure_clean_working_directory
def ensure_clean_working_directory(self, force):
if not force and not self.working_directory_is_clean():
print self.run_command(self.status_command(), error_handler=ignore_error)
raise ScriptError(message="Working directory has modifications, pass --force-clean or --no-clean to continue.")
log("Cleaning working directory")
self.clean_working_directory()
示例11: prompt_for_component
def prompt_for_component(self, components):
log("Please pick a component:")
i = 0
for name in components:
i += 1
log("%2d. %s" % (i, name))
result = int(raw_input("Enter a number: ")) - 1
return components[result]
示例12: _guess_reviewer_from_bug
def _guess_reviewer_from_bug(self, bug_id):
patches = self._tool.bugs.fetch_reviewed_patches_from_bug(bug_id)
if len(patches) != 1:
log("%s on bug %s, cannot infer reviewer." % (pluralize("reviewed patch", len(patches)), bug_id))
return None
patch = patches[0]
reviewer = patch["reviewer"]
log("Guessing \"%s\" as reviewer from attachment %s on bug %s." % (reviewer, patch["id"], bug_id))
return reviewer
示例13: run
def run(self, state):
if not self._options.obsolete_patches:
return
bug_id = state["bug_id"]
patches = self._tool.bugs.fetch_patches_from_bug(bug_id)
if not patches:
return
log("Obsoleting %s on bug %s" % (pluralize("old patch", len(patches)), bug_id))
for patch in patches:
self._tool.bugs.obsolete_attachment(patch["id"])
示例14: execute
def execute(self, options, args, tool):
self._prepare_to_process(options, args, tool)
patches = self._fetch_list_of_patches_to_process(options, args, tool)
# It's nice to print out total statistics.
bugs_to_patches = self._collect_patches_by_bug(patches)
log("Processing %s from %s." % (pluralize("patch", len(patches)), pluralize("bug", len(bugs_to_patches))))
for patch in patches:
self._process_patch(patch, options, args, tool)
示例15: run_and_handle_errors
def run_and_handle_errors(self, tool, options, state=None):
if not state:
state = {}
try:
self._run(tool, options, state)
except CheckoutNeedsUpdate, e:
log("Commit failed because the checkout is out of date. Please update and try again.")
log(
"You can pass --no-build to skip building/testing after update if you believe the new commits did not affect the results."
)
QueueEngine.exit_after_handled_error(e)