本文整理汇总了Python中supybot.log.exception函数的典型用法代码示例。如果您正苦于以下问题:Python exception函数的具体用法?Python exception怎么用?Python exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exception函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_bug
def get_bug(self, id): # This is still a little rough, but it works :)
url = "%s/%d" % (self.url, id)
try:
raw = utils.web.getUrl("%s?format=tab" % url).decode('utf-8')
except Exception as e:
# Due to unreliable matching
if '.' in self.name:
supylog.exception(self.errget % (self.description, e, url))
return
if 'HTTP Error 500' in str(e):
raise BugNotFoundError
raise BugtrackerError(self.errget % (self.description, e, url))
raw = raw.replace('\r\n', '\n')
(headers, rest) = raw.split('\n', 1)
headers = headers.strip().split('\t')
rest = rest.strip().split('\t')
title = status = package = severity = assignee = ""
if "summary" in headers:
title = rest[headers.index("summary")]
if "status" in headers:
status = rest[headers.index("status")]
if "component" in headers:
package = rest[headers.index("component")]
if "severity" in headers:
severity = rest[headers.index("severity")]
elif "priority" in headers:
severity = rest[headers.index("priority")]
if "owner" in headers:
assignee = rest[headers.index("owner")]
return (id, package, title, severity, status, assignee, url, [], [])
开发者ID:mapreri,项目名称:MPR-supybot,代码行数:31,代码来源:plugin.py
示例2: __init__
def __init__(self, *args, **kwargs):
IBugtracker.__init__(self, *args, **kwargs)
self.lp = None
# A word to the wise:
# The Launchpad API is much better than the /+text interface we currently use,
# it's faster and easier to get the information we need.
# The current /+text interface is not really maintained by Launchpad and most,
# or all, of the Launchpad developers hate it. For this reason, we are dropping
# support for /+text in the future in favour of launchpadlib.
# Terence Simpson (tsimpson) 2010-04-20
try: # Attempt to use launchpadlib, python bindings for the Launchpad API
from launchpadlib.launchpad import Launchpad
cachedir = os.path.join(conf.supybot.directories.data.tmp(), 'lpcache')
if hasattr(Launchpad, 'login_anonymously'):
self.lp = Launchpad.login_anonymously("Ubuntu Bots - Bugtracker", 'production', cachedir)
else: #NOTE: Most people should have a launchpadlib new enough for .login_anonymously
self.lp = Launchpad.login("Ubuntu Bots - Bugtracker", '', '', 'production', cahedir)
except ImportError:
# Ask for launchpadlib to be installed
supylog.warning("Please install python-launchpadlib, the old interface is deprecated")
except Exception: # Something unexpected happened
self.lp = None
supylog.exception("Unknown exception while accessing the Launchpad API")
开发者ID:bnrubin,项目名称:Bugtracker,代码行数:25,代码来源:plugin.py
示例3: flush
def flush():
"""Flushes all the registered flushers."""
for (i, f) in enumerate(flushers):
try:
f()
except Exception, e:
log.exception("Uncaught exception in flusher #%s (%s):", i, f)
开发者ID:resistivecorpse,项目名称:Limnoria,代码行数:7,代码来源:world.py
示例4: _loadPlugins
def _loadPlugins(self, irc):
self.log.info('Loading plugins (connecting to %s).', irc.network)
alwaysLoadImportant = conf.supybot.plugins.alwaysLoadImportant()
important = conf.supybot.commands.defaultPlugins.importantPlugins()
for (name, value) in conf.supybot.plugins.getValues(fullNames=False):
if irc.getCallback(name) is None:
load = value()
if not load and name in important:
if alwaysLoadImportant:
s = '%s is configured not to be loaded, but is being '\
'loaded anyway because ' \
'supybot.plugins.alwaysLoadImportant is True.'
self.log.warning(s, name)
load = True
if load:
# We don't load plugins that don't start with a capital
# letter.
if name[0].isupper() and not irc.getCallback(name):
# This is debug because each log logs its beginning.
self.log.debug('Loading %s.', name)
try:
m = plugin.loadPluginModule(name,
ignoreDeprecation=True)
plugin.loadPluginClass(irc, m)
except callbacks.Error, e:
# This is just an error message.
log.warning(str(e))
except (plugins.NoSuitableDatabase, ImportError), e:
s = 'Failed to load %s: %s' % (name, e)
if not s.endswith('.'):
s += '.'
log.warning(s)
except Exception, e:
log.exception('Failed to load %s:', name)
开发者ID:boamaod,项目名称:Limnoria,代码行数:34,代码来源:plugin.py
示例5: _runCommandFunction
def _runCommandFunction(self, irc, msg, command):
"""Run a command from message, as if command was sent over IRC."""
tokens = callbacks.tokenize(command)
try:
self.Proxy(irc.irc, msg, tokens)
except Exception, e:
log.exception('Uncaught exception in function called by MessageParser:')
开发者ID:mazaclub,项目名称:mazabot-core,代码行数:7,代码来源:plugin.py
示例6: get_bug_new
def get_bug_new(self, id): #TODO: Rename this method to 'get_bug'
try:
bugdata = self.lp.bugs[id]
if bugdata.private:
raise BugtrackerError, "This bug is private"
dup = bugdata.duplicate_of
summary_prefix = '' # Used to made dups easier
while dup:
summary_prefix = 'duplicate for #%d ' % id
bugdata = dup
dup = bugdata.duplicate_of
affected = bugdata.users_affected_count_with_dupes
heat = bugdata.heat
tasks = bugdata.bug_tasks
if tasks.total_size != 1:
tasks = list(tasks)
try:
tasks.sort(self._sort)
taskdata = tasks[-1]
except ValueError:
tasks = [_ for _ in tasks if _.bug_target_name.endswith(u'(Ubuntu)')]
if tasks:
if len(tasks) != 1:
try:
tasks.sort(self._sort)
taskdata = tasks[-1]
except ValueError:
taskdata = bugdata.bug_tasks[bugdata.bug_tasks.total_size - 1]
else:
taskdata = tasks[-1]
else:
taskdata = tasks[-1]
else:
taskdata = tasks[0]
assignee = taskdata.assignee
t = taskdata.bug_target_display_name #task name
if assignee: # "Diaplay Name (Launchpad ID)"
assignee = u"%s (%s)" % (assignee.display_name, assignee.name)
else:
assignee = ''
except Exception, e:
if type(e).__name__ == 'HTTPError': # messy, but saves trying to import lazr.restfulclient.errors.HTPError
if e.response.status == 404:
bugNo = e.content.split(None)[-1][2:-1] # extract the real bug number
if bugNo != str(id): # A duplicate of a private bug, at least we know it exists
raise BugtrackerError, 'Bug #%s is a duplicate of bug #%s, but it is private (%s/bugs/%s)' % (id, bugNo, self.url, bugNo)
raise BugtrackerError, "Bug #%s (%s/bugs/%d) is private or doesn't exist" % (id, self.url, id) # Could be private, could just not exist
supylog.exception("Error gathering bug data for %s bug #%d" % (self.description, id))
raise BugtrackerError, "Could not gather data from %s for bug #%s (%s/bugs/%s). The error has been logged" % (self.description, id, self.url, id)
elif isinstance(e, KeyError):
raise BugNotFoundError
supylog.exception("Error gathering bug data for %s bug %d" % (self.description, id))
raise BugtrackerError, "Could not gather data from %s for bug #%s (%s/bugs/%s). The error has been logged" % (self.description, id, self.url, id)
开发者ID:bnrubin,项目名称:Bugtracker,代码行数:59,代码来源:plugin.py
示例7: newf
def newf(*args, **kwargs):
for x in range(0, 3):
try:
return f(*args, **kwargs)
except Exception:
log.exception('Shrinking URL failed. Trying again.')
time.sleep(1)
return f(*args, **kwargs)
开发者ID:limebot,项目名称:LimeBot,代码行数:8,代码来源:plugin.py
示例8: _loadPlugins
def _loadPlugins(self, irc):
self.log.info('Loading plugins (connecting to %s).', irc.network)
alwaysLoadImportant = conf.supybot.plugins.alwaysLoadImportant()
important = conf.supybot.commands.defaultPlugins.importantPlugins()
for (name, value) in conf.supybot.plugins.getValues(fullNames=False):
if irc.getCallback(name) is None:
load = value()
if not load and name in important:
if alwaysLoadImportant:
s = '%s is configured not to be loaded, but is being '\
'loaded anyway because ' \
'supybot.plugins.alwaysLoadImportant is True.'
self.log.warning(s, name)
load = True
if load:
# We don't load plugins that don't start with a capital
# letter.
if name[0].isupper() and not irc.getCallback(name):
# This is debug because each log logs its beginning.
self.log.debug('Loading %s.', name)
try:
m = plugin.loadPluginModule(name,
ignoreDeprecation=True)
plugin.loadPluginClass(irc, m)
except callbacks.Error as e:
# This is just an error message.
log.warning(str(e))
except plugins.NoSuitableDatabase as e:
s = 'Failed to load %s: no suitable database(%s).' % (
name, e)
log.warning(s)
except ImportError as e:
e = str(e)
if e.endswith(name):
s = 'Failed to load {0}: No plugin named {0} exists.'.format(
utils.str.dqrepr(name))
elif "No module named 'config'" in e:
s = (
"Failed to load %s: This plugin may be incompatible "
"with your current Python version. If this error is appearing "
"with stock Supybot plugins, remove the stock plugins directory "
"(usually ~/Limnoria/plugins) from 'config directories.plugins'." %
name)
else:
s = 'Failed to load %s: import error (%s).' % (
name, e)
log.warning(s)
except Exception as e:
log.exception('Failed to load %s:', name)
else:
# Let's import the module so configuration is preserved.
try:
_ = plugin.loadPluginModule(name)
except Exception as e:
log.debug('Attempted to load %s to preserve its '
'configuration, but load failed: %s',
name, e)
world.starting = False
开发者ID:Brilliant-Minds,项目名称:Limnoria-Plugins,代码行数:58,代码来源:plugin.py
示例9: _email_callback
def _email_callback(self, fileobj):
try:
email = parse_mail(fileobj)
msg = get_message(email, new_queue=self.new_queue)
if not msg:
return
txt = colourise(msg.for_irc())
# Simple flood/duplicate detection
if txt in self.last_n_messages:
return
self.last_n_messages.insert(0, txt)
self.last_n_messages = self.last_n_messages[:20]
for channel in self.irc.state.channels:
package_regex = self.registryValue(
'package_regex',
channel,
) or 'a^' # match nothing by default
package_match = re.search(package_regex, msg.package)
maintainer_match = False
maintainer_regex = self.registryValue(
'maintainer_regex',
channel)
if maintainer_regex:
info = Maintainer().get_maintainer(msg.package)
if info:
maintainer_match = re.search(maintainer_regex, info['email'])
if not package_match and not maintainer_match:
continue
distribution_regex = self.registryValue(
'distribution_regex',
channel,
)
if distribution_regex:
if not hasattr(msg, 'distribution'):
# If this channel has a distribution regex, don't
# bother continuing unless the message actually has a
# distribution. This filters security messages, etc.
continue
if not re.search(distribution_regex, msg.distribution):
# Distribution doesn't match regex; don't send this
# message.
continue
ircmsg = supybot.ircmsgs.privmsg(channel, txt)
self.irc.queueMsg(ircmsg)
except Exception as e:
log.exception('Uncaught exception: %s ' % e)
开发者ID:xtaran,项目名称:debian-devel-changes-bot,代码行数:58,代码来源:plugin.py
示例10: flush
def flush(self):
"""Exports the database to a file."""
tmp_filename = self.filename + '.tmp'
try:
with open(tmp_filename, 'wb') as f:
pickle.dump(self.db, f, 2)
os.rename(tmp_filename, self.filename)
except Exception as e:
log.exception('%s: Unable to write database: %s', self._plugin_name, e)
开发者ID:GLolol,项目名称:SupyPlugins,代码行数:9,代码来源:accountsdb.py
示例11: _dispatch
def _dispatch(self, name, args):
if name not in self.connector.rpcMethods:
raise TypeError('no such method (%s)' % name)
try:
return self.connector.rpcMethods[name](*args)
except Fault:
raise
except:
log.exception('Unhandled exception in Trac XMLRPC:')
raise
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:10,代码来源:plugin.py
示例12: __del__
def __del__(self):
try:
Connection.__del__(self)
except AttributeError:
pass
except Exception, e:
try:
log.exception('Uncaught exception in __del__:')
except:
pass
开发者ID:Elwell,项目名称:supybot,代码行数:10,代码来源:__init__.py
示例13: run
def run(self):
if len(drivers._drivers) == 1 and not world.testing:
log.error('Schedule is the only remaining driver, '
'why do we continue to live?')
time.sleep(1) # We're the only driver; let's pause to think.
while self.schedule and self.schedule[0][0] < time.time():
(t, name) = heapq.heappop(self.schedule)
f = self.events[name]
del self.events[name]
try:
f()
except Exception, e:
log.exception('Uncaught exception in scheduled function:')
开发者ID:Criptomonedas,项目名称:supybot_fixes,代码行数:13,代码来源:schedule.py
示例14: open
def open(self, filename):
self.filename = filename
reader = unpreserve.Reader(IrcUserCreator, self)
try:
self.noFlush = True
try:
reader.readFile(filename)
self.noFlush = False
self.flush()
except EnvironmentError, e:
log.error('Invalid user dictionary file, resetting to empty.')
log.error('Exact error: %s', utils.exnToString(e))
except Exception, e:
log.exception('Exact error:')
开发者ID:Elwell,项目名称:supybot,代码行数:14,代码来源:ircdb.py
示例15: open
def open(self, filename):
self.noFlush = True
try:
self.filename = filename
reader = unpreserve.Reader(IrcChannelCreator, self)
try:
reader.readFile(filename)
self.noFlush = False
self.flush()
except EnvironmentError, e:
log.error("Invalid channel database, resetting to empty.")
log.error("Exact error: %s", utils.exnToString(e))
except Exception, e:
log.error("Invalid channel database, resetting to empty.")
log.exception("Exact error:")
开发者ID:jrabbit,项目名称:ubotu-fr,代码行数:15,代码来源:ircdb.py
示例16: get_bug_old
def get_bug_old(self, id): # Deprecated
url = "%s/view.php?id=%d" % (self.url, id)
try:
raw = self.soap_client.mc_issue_get(username='', password='', issue_id=id)
except Exception as e:
if 'Issue #%d not found' % id in str(e):
raise BugNotFoundError
# Often SOAP is not enabled
if '.' in self.name:
supylog.exception(self.errget % (self.description, e, url))
return
raise BugtrackerError(self.errget % (self.description, e, url))
if not hasattr(raw, 'id'):
raise BugNotFoundError
try:
return (id, str(raw.project.name), str(raw.summary), str(raw.severity.name), str(raw.resolution.name), '', url, [], [])
except Exception as e:
raise BugtrackerError(self.errparse % (self.description, e, url))
开发者ID:mapreri,项目名称:MPR-supybot,代码行数:18,代码来源:plugin.py
示例17: __init__
def __init__(self, *args, **kwargs):
IBugtracker.__init__(self, *args, **kwargs)
self.lp = None
# A word to the wise:
# The Launchpad API is much better than the /+text interface we currently use,
# it's faster and easier to get the information we need.
# The current /+text interface is not really maintained by Launchpad and most,
# or all, of the Launchpad developers hate it. For this reason, we are dropping
# support for /+text in the future in favour of launchpadlib.
# Terence Simpson (tsimpson) 2010-04-20
try:
from launchpadlib.launchpad import Launchpad
cachedir = os.path.join(conf.supybot.directories.data.tmp(), 'launchpadlib')
self.lp = Launchpad.login_anonymously("Ubuntu Bots - Bugtracker", 'production', cachedir, version='devel')
except ImportError:
supylog.warning("Please install python-launchpadlib, the old interface is deprecated")
except Exception:
self.lp = None
supylog.exception("Unknown exception while accessing the Launchpad API")
开发者ID:mapreri,项目名称:MPR-supybot,代码行数:21,代码来源:plugin.py
示例18: process_mails
def process_mails(self):
log.info("Mail processing thread started.")
while not self.quit:
with self.cv:
while not self.quit and len(self.messages) == 0:
log.debug("Waiting for new mail.")
self.cv.wait()
if self.quit:
log.info("Mail processing thread stopeed.")
self.thread = None
return
mail = self.messages.popleft()
log.debug("Got mail.")
mail = base64.b64decode(mail.encode('ascii'))
try:
self.callback(BytesIO(mail))
except Exception as e:
log.exception('Uncaught exception: {}'.format(e))
self.thread = None
开发者ID:lamby,项目名称:debian-devel-changes-bot,代码行数:23,代码来源:dbus.py
示例19: _email_callback
def _email_callback(self, fileobj):
try:
email = parse_mail(fileobj)
msg = get_message(email)
if not msg:
return
txt = colourise(msg.for_irc())
# Simple flood/duplicate detection
if txt in self.last_n_messages:
return
self.last_n_messages.insert(0, txt)
self.last_n_messages = self.last_n_messages[:20]
for channel in self.irc.state.channels:
regex = self.registryValue('package_regex', channel) or 'a^'
if re.search(regex, msg.package):
ircmsg = supybot.ircmsgs.privmsg(channel, txt)
self.irc.queueMsg(ircmsg)
except:
log.exception('Uncaught exception')
开发者ID:rhonda,项目名称:debian-devel-changes-bot,代码行数:24,代码来源:plugin.py
示例20: _ticker
def _ticker(self, irc, ticker):
prev = dict()
while True:
if self.stop:
return
try:
log.debug("refreshing ticker %r", ticker)
data = dict()
for key, url in TICKERS[ticker]['urls'].iteritems():
log.debug("fetching url %r", url)
try:
t0 = time.time()
data[key] = json.load(urllib2.urlopen(url, timeout=30))
except Exception, e:
log.exception("error fetching %r", url)
continue
log.info("fetched %r in %.2f s", url, time.time() - t0)
log.debug("data = %r", data[key])
if not data:
raise Exception("no data for ticker %s" % repr(ticker))
for output, o in TICKERS[ticker]['outputs'].iteritems():
log.debug("processing output %r: %r", output, o)
values = []
diffstring = ''
report = False
low = high = None
for metric, m in o['metrics'].iteritems():
value = d(getvalue(data, m[1:])).quantize(m[0])
if metric == 'volume': # volume is in base units
currency = o['unit']
else: # others are in currency
currency = o['currency']
log.debug("output %r metric %r has value %r", output, metric, value)
if metric in o['reportchange']:
if output+metric in prev:
vdiff = value - prev[output+metric]
else:
vdiff = Decimal(0)
prev[output+metric] = value
report = True
if vdiff.copy_abs() >= o['reportchange'][metric]:
log.debug("output %r metric %r value diff %r exceeds %r, reporting change",
output, metric, vdiff.copy_abs(), o['reportchange'][metric])
prev[output+metric] = value
report = True
values.append("%12s %-3s" % (
value, currency))
diffstring = updown(vdiff)
else:
values.append("%12s %-3s" % (
value, currency))
if low is None or value < low:
low = value
if high is None or value > high:
high = value
diffstring=updown(vdiff, '(%s%s %s)' % (
'-' if vdiff.is_signed() else '+',
vdiff.copy_abs(), currency))
out = "%s %s %s %s" % (
'['+TICKERS[ticker]['label']+']',
currencycolor(o['unit']),
" ".join(values),
diffstring)
if report:
for chan in self.registryValue('channels'):
irc.queueMsg(ircmsgs.privmsg(chan,
ircutils.bold(out)))
nicks = self.lowvalues.keys()
for nick in nicks:
user_value = self.lowvalues[nick]
if low is not None and low <= user_value:
out = "%s: OMG, it went below %s to %s!" % (nick, user_value, low)
irc.queueMsg(ircmsgs.privmsg(chan, ircutils.bold(out)))
del self.lowvalues[nick]
nicks = self.highvalues.keys()
for nick in nicks:
user_value = self.highvalues[nick]
if high is not None and high >= user_value:
out = "%s: OMG, it went above %s to %s!" % (nick, user_value, high)
irc.queueMsg(ircmsgs.privmsg(chan, ircutils.bold(out)))
del self.highvalues[nick]
except Exception, e:
log.exception("in ticker thread %r", ticker)
开发者ID:loisaidasam,项目名称:idioterna-stuff,代码行数:85,代码来源:plugin.py
注:本文中的supybot.log.exception函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论