本文整理汇总了Python中twisted.python.log.msg函数的典型用法代码示例。如果您正苦于以下问题:Python msg函数的具体用法?Python msg怎么用?Python msg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了msg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main(reactor):
d5 = defer.Deferred().addCallback(log.msg)
reactor.callLater(0.3, d5.callback, "########## simulated request 1 ############")
d6 = defer.Deferred().addCallback(log.msg)
reactor.callLater(0.5, d6.callback, "########## sim request 2 ############")
d7 = defer.Deferred().addCallback(log.msg)
reactor.callLater(0.7, d7.callback, "########## simulated request 3 ############")
# simulate an external event triggering an expensive computation while
# other expensive computations are happening.
d8 = defer.Deferred()
d8.addCallback(do_some_expensive_things)
reactor.callLater(0.1, d8.callback, 201)
numbers = [54.0, 42, 10, 34]
for number in numbers:
result = list(expensive(number))
log.msg("first for {}: {}".format(number, reduce(add, result, 0)))
result = list(expensive(number))
log.msg("second for {}: {}".format(number, reduce(add, result, 0)))
return defer.gatherResults([d5, d6, d7, d8]).addCallback(log.msg)
示例2: run
def run(self):
log.msg("Running bot as %r" % self.name)
self.irc = BottuClientFactory(self)
self.join_passive_channel.ready()
reactor.connectTCP(self.network, self.port, self.irc)
reactor.run()
log.msg("Stopping bot")
示例3: stepDone
def stepDone(self, result, step):
"""This method is called when the BuildStep completes. It is passed a
status object from the BuildStep and is responsible for merging the
Step's results into those of the overall Build."""
terminate = False
text = None
if type(result) == types.TupleType:
result, text = result
assert type(result) == type(SUCCESS)
log.msg(" step '%s' complete: %s" % (step.name, Results[result]))
self.results.append(result)
if text:
self.text.extend(text)
if not self.remote:
terminate = True
if result == FAILURE:
if step.warnOnFailure:
if self.result != FAILURE:
self.result = WARNINGS
if step.flunkOnFailure:
self.result = FAILURE
if step.haltOnFailure:
terminate = True
elif result == WARNINGS:
if step.warnOnWarnings:
if self.result != FAILURE:
self.result = WARNINGS
if step.flunkOnWarnings:
self.result = FAILURE
elif result == EXCEPTION:
self.result = EXCEPTION
terminate = True
return terminate
示例4: _enterRawMode
def _enterRawMode():
global _inRawMode, _savedRawMode
if _inRawMode:
return
fd = sys.stdin.fileno()
try:
old = tty.tcgetattr(fd)
new = old[:]
except:
log.msg('not a typewriter!')
else:
# iflage
new[0] = new[0] | tty.IGNPAR
new[0] = new[0] & ~(tty.ISTRIP | tty.INLCR | tty.IGNCR | tty.ICRNL |
tty.IXON | tty.IXANY | tty.IXOFF)
if hasattr(tty, 'IUCLC'):
new[0] = new[0] & ~tty.IUCLC
# lflag
new[3] = new[3] & ~(tty.ISIG | tty.ICANON | tty.ECHO | tty.ECHO |
tty.ECHOE | tty.ECHOK | tty.ECHONL)
if hasattr(tty, 'IEXTEN'):
new[3] = new[3] & ~tty.IEXTEN
#oflag
new[1] = new[1] & ~tty.OPOST
new[6][tty.VMIN] = 1
new[6][tty.VTIME] = 0
_savedRawMode = old
tty.tcsetattr(fd, tty.TCSANOW, new)
#tty.setraw(fd)
_inRawMode = 1
示例5: startBuild
def startBuild(self):
scheds = self.master.db.schedulers
# if onlyIfChanged is True, then we will skip this build if no
# important changes have occurred since the last invocation
if self.onlyIfChanged:
classifications = \
yield scheds.getChangeClassifications(self.objectid)
# see if we have any important changes
for imp in classifications.itervalues():
if imp:
break
else:
log.msg(("Nightly Scheduler <%s>: skipping build " +
"- No important changes on configured branch") % self.name)
return
changeids = sorted(classifications.keys())
yield self.addBuildsetForChanges(reason=self.reason,
changeids=changeids)
max_changeid = changeids[-1] # (changeids are sorted)
yield scheds.flushChangeClassifications(self.objectid,
less_than=max_changeid+1)
else:
# start a build of the latest revision, whatever that is
yield self.addBuildsetForLatest(reason=self.reason,
branch=self.branch)
示例6: run
def run(self):
framelog = os.path.join(self.basedir, "driver.log")
log.startLogging(open(framelog, "a"), setStdout=False)
log.msg("CHECK_MEMORY(mode=%s) STARTING" % self.mode)
#logfile = open(os.path.join(self.testdir, "log"), "w")
#flo = log.FileLogObserver(logfile)
#log.startLoggingWithObserver(flo.emit, setStdout=False)
d = fireEventually()
d.addCallback(lambda res: self.setUp())
d.addCallback(lambda res: self.record_initial_memusage())
d.addCallback(lambda res: self.make_nodes())
d.addCallback(lambda res: self.wait_for_client_connected())
d.addCallback(lambda res: self.do_test())
d.addBoth(self.tearDown)
def _err(err):
self.failed = err
log.err(err)
print err
d.addErrback(_err)
def _done(res):
reactor.stop()
return res
d.addBoth(_done)
reactor.run()
if self.failed:
# raiseException doesn't work for CopiedFailures
self.failed.raiseException()
示例7: onConnect
def onConnect():
# if keyAgent and options['agent']:
# cc = protocol.ClientCreator(reactor, SSHAgentForwardingLocal, conn)
# cc.connectUNIX(os.environ['SSH_AUTH_SOCK'])
if hasattr(conn.transport, 'sendIgnore'):
_KeepAlive(conn)
if options.localForwards:
for localPort, hostport in options.localForwards:
s = reactor.listenTCP(localPort,
forwarding.SSHListenForwardingFactory(conn,
hostport,
SSHListenClientForwardingChannel))
conn.localForwards.append(s)
if options.remoteForwards:
for remotePort, hostport in options.remoteForwards:
log.msg('asking for remote forwarding for %s:%s' %
(remotePort, hostport))
conn.requestRemoteForwarding(remotePort, hostport)
reactor.addSystemEventTrigger('before', 'shutdown', beforeShutdown)
if not options['noshell'] or options['agent']:
conn.openChannel(SSHSession())
if options['fork']:
if os.fork():
os._exit(0)
os.setsid()
for i in range(3):
try:
os.close(i)
except OSError as e:
import errno
if e.errno != errno.EBADF:
raise
示例8: start_instance_result
def start_instance_result(result):
# If we don't report success, then preparation failed.
if not result:
log.msg(
"Worker '%s' does not want to substantiate at this time" % (self.name,))
self._substantiation_notifier.notify(False)
return result
示例9: _soft_disconnect
def _soft_disconnect(self, fast=False):
# a negative build_wait_timeout means the worker should never be shut
# down, so just disconnect.
if self.build_wait_timeout < 0:
yield AbstractWorker.disconnect(self)
return
if self.missing_timer:
self.missing_timer.cancel()
self.missing_timer = None
if self._substantiation_notifier:
log.msg("Weird: Got request to stop before started. Allowing "
"worker to start cleanly to avoid inconsistent state")
yield self._substantiation_notifier.wait()
self.substantiation_build = None
log.msg("Substantiation complete, immediately terminating.")
if self.conn is not None:
yield defer.DeferredList([
AbstractWorker.disconnect(self),
self.insubstantiate(fast)
], consumeErrors=True, fireOnOneErrback=True)
else:
yield AbstractWorker.disconnect(self)
yield self.stop_instance(fast)
示例10: _mail_missing_message
def _mail_missing_message(self, subject, text):
# FIXME: This should be handled properly via the event api
# we should send a missing message on the mq, and let any reporter
# handle that
# first, see if we have a MailNotifier we can use. This gives us a
# fromaddr and a relayhost.
buildmaster = self.botmaster.master
for st in buildmaster.services:
if isinstance(st, MailNotifier):
break
else:
# if not, they get a default MailNotifier, which always uses SMTP
# to localhost and uses a dummy fromaddr of "buildbot".
log.msg("worker-missing msg using default MailNotifier")
st = MailNotifier("buildbot")
# now construct the mail
m = Message()
m.set_payload(text)
m['Date'] = formatdate(localtime=True)
m['Subject'] = subject
m['From'] = st.fromaddr
recipients = self.notify_on_missing
m['To'] = ", ".join(recipients)
d = st.sendMessage(m, recipients)
# return the Deferred for testing purposes
return d
示例11: shutdown
def shutdown(self):
"""Shutdown the worker"""
if not self.conn:
log.msg("no remote; worker is already shut down")
return
yield self.conn.remoteShutdown()
示例12: releaseLocks
def releaseLocks(self):
"""
I am called to release any locks after a build has finished
"""
log.msg("releaseLocks(%s): %s" % (self, self.locks))
for lock, access in self.locks:
lock.release(self, access)
示例13: process
def process(self):
log.msg("PROCESS: %s" % id(self))
log.msg("URI:%s PATH %s" % (self.uri, self.path + str(self.args)))
log.msg(
"Request:\n\t%s"
% "\n\t".join(("%s\t%s" % (x[0], ";".join(x[1])) for x in self.requestHeaders.getAllRawHeaders()))
)
session = Session(self)
session.preRequest()
host = self.getHeader("host")
if not host:
log.err("No host header given")
self.setResponseCode(400)
self.finish()
return
port = 80
if ":" in host:
host, port = host.split(":")
port = int(port)
self.setHost(host, port)
log.msg("URI:%s PATH %s" % (self.uri, self.path + str(self.args)))
log.msg(
"Request:\n\t%s"
% "\n\t".join(("%s\t%s" % (x[0], ";".join(x[1])) for x in self.requestHeaders.getAllRawHeaders()))
)
self.content.seek(0, 0)
postData = self.content.read()
factory = ProxyClientFactory(self.method, self.uri, postData, self.requestHeaders.getAllRawHeaders(), session)
self.reactor.connectTCP(host, port, factory)
示例14: _readAndWrite
def _readAndWrite(self, source, condition):
# note: gtk-1.2's gtk_input_add presents an API in terms of gdk
# constants like INPUT_READ and INPUT_WRITE. Internally, it will add
# POLL_HUP and POLL_ERR to the poll() events, but if they happen it
# will turn them back into INPUT_READ and INPUT_WRITE. gdkevents.c
# maps IN/HUP/ERR to INPUT_READ, and OUT/ERR to INPUT_WRITE. This
# means there is no immediate way to detect a disconnected socket.
# The g_io_add_watch() API is more suited to this task. I don't think
# pygtk exposes it, though.
why = None
didRead = None
try:
if condition & gtk.GDK.INPUT_READ:
why = source.doRead()
didRead = source.doRead
if not why and condition & gtk.GDK.INPUT_WRITE:
# if doRead caused connectionLost, don't call doWrite
# if doRead is doWrite, don't call it again.
if not source.disconnected and source.doWrite != didRead:
why = source.doWrite()
didRead = source.doWrite # if failed it was in write
except:
why = sys.exc_info()[1]
log.msg('Error In %s' % source)
log.deferr()
if why:
self._disconnectSelectable(source, why, didRead == source.doRead)
示例15: getAndCheckProperties
def getAndCheckProperties(req):
"""
Fetch custom build properties from the HTTP request of a "Force build" or
"Resubmit build" HTML form.
Check the names for valid strings, and return None if a problem is found.
Return a new Properties object containing each property found in req.
"""
master = req.site.buildbot_service.master
pname_validate = master.config.validation['property_name']
pval_validate = master.config.validation['property_value']
properties = Properties()
i = 1
while True:
pname = req.args.get("property%dname" % i, [""])[0]
pvalue = req.args.get("property%dvalue" % i, [""])[0]
if not pname:
break
if not pname_validate.match(pname) \
or not pval_validate.match(pvalue):
log.msg("bad property name='%s', value='%s'" % (pname, pvalue))
return None
properties.setProperty(pname, pvalue, "Force Build Form")
i = i + 1
return properties