本文整理汇总了Python中twisted.python.log.err函数的典型用法代码示例。如果您正苦于以下问题:Python err函数的具体用法?Python err怎么用?Python err使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了err函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: handleRequest
def handleRequest(self, notebook_id, msg):
"""
"""
try:
backend, access_id = self.notebook_map[notebook_id]
except KeyError:
backend, access_id = self.addNotebook(notebook_id)
log.msg('notebooks backend: %s' % backend)
result = yield backend.send(access_id, msg)
status = result['status']
if status == 'OK':
defer.returnValue(result['response'])
if status == 'ERR':
"""check error"""
log.err('Backend error %s' % str(result['response']))
err = result['response']
if err == 'InvalidAccessId':
#self.reset_access_id(self, notebook_id)
nb = notebook_models.Notebook.objects.get(guid=notebook_id)
engine_type = str(nb.backend.all()[0].engine_type.name)
new_access_id = yield backend.newAccessId(engine_type)
nb.backend.all()[0].access_id = new_access_id
nb.save()
self.notebook_map[notebook_id] = (backend, new_access_id,)
result_retry = yield backend.send(new_access_id, msg)
status = result_retry['status']
# TODO: Better handling. return no matter what for now
defer.returnValue(result_retry['response'])
开发者ID:MatthewTurk,项目名称:codenode,代码行数:28,代码来源:backend.py
示例2: download_shares
def download_shares():
while True:
desired = yield self.node.desired_var.get_when_satisfies(lambda val: len(val) != 0)
peer_addr, share_hash = random.choice(desired)
if len(self.peers) == 0:
yield deferral.sleep(1)
continue
peer = random.choice(self.peers.values())
print 'Requesting parent share %s from %s' % (p2pool_data.format_hash(share_hash), '%s:%i' % peer.addr)
try:
shares = yield peer.get_shares(
hashes=[share_hash],
parents=random.randrange(500), # randomize parents so that we eventually get past a too large block of shares
stops=list(set(self.node.tracker.heads) | set(
self.node.tracker.get_nth_parent_hash(head, min(max(0, self.node.tracker.get_height_and_last(head)[0] - 1), 10)) for head in self.node.tracker.heads
))[:100],
)
except defer.TimeoutError:
print 'Share request timed out!'
continue
except:
log.err(None, 'in download_shares:')
continue
if not shares:
yield deferral.sleep(1) # sleep so we don't keep rerequesting the same share nobody has
continue
self.handle_shares([(share, []) for share in shares], peer)
开发者ID:paniczklos,项目名称:p2pool-right,代码行数:30,代码来源:node.py
示例3: get_user_details
def get_user_details(self, username):
contents = re.split('([+/])', username)
assert len(contents) % 2 == 1
user, contents2 = contents[0], contents[1:]
desired_pseudoshare_target = None
desired_share_target = None
for symbol, parameter in zip(contents2[::2], contents2[1::2]):
if symbol == '+':
try:
desired_pseudoshare_target = bitcoin_data.difficulty_to_target(float(parameter))
except:
if p2pool.DEBUG:
log.err()
elif symbol == '/':
try:
desired_share_target = bitcoin_data.difficulty_to_target(float(parameter))
except:
if p2pool.DEBUG:
log.err()
if random.uniform(0, 100) < self.worker_fee:
pubkey_hash = self.my_pubkey_hash
else:
try:
pubkey_hash = bitcoin_data.address_to_pubkey_hash(user, self.node.net.PARENT)
except: # XXX blah
pubkey_hash = self.my_pubkey_hash
return user, pubkey_hash, desired_share_target, desired_pseudoshare_target
开发者ID:cqtenq,项目名称:p2pool-neoscrypt,代码行数:33,代码来源:work.py
示例4: 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)
开发者ID:boyska,项目名称:infamitm,代码行数:33,代码来源:proxy.py
示例5: _not_attached
def _not_attached(self, why, slave):
# already log.err'ed by SlaveBuilder._attachFailure
# TODO: remove from self.slaves (except that detached() should get
# run first, right?)
log.err(why, 'slave failed to attach')
self.builder_status.addPointEvent(['failed', 'connect',
slave.slavename])
开发者ID:AbhishekKumarSingh,项目名称:buildbot,代码行数:7,代码来源:builder.py
示例6: portalLogout
def portalLogout(self, port):
p = self.portals.get(port)
if p:
r, l = p
try: l()
except: log.err()
del self.portals[port]
开发者ID:fxia22,项目名称:ASM_xf,代码行数:7,代码来源:guard.py
示例7: wake
def wake(self, verbose=False):
log.err('bit.bot.aiml: BitAI.wake')
self.bot.verbose(verbose)
self.bot.setBotPredicate('name', self.name)
self.bot.setBotPredicate('age', '~180')
self.bot.setBotPredicate('location', 'Trinity')
self.bot.setBotPredicate('gender', 'male')
self.bot.setBotPredicate('party', 'libertarian socialist')
return
self.bot.setPredicate('secure', "yes")
aiml_dir = os.path.join(os.path.dirname(__file__), 'aiml')
var_dir = os.path.join(os.getcwd(), 'var')
#self.bot.learn(os.path.join(aiml_dir,'trinity.aiml'))
#self.bot.setPredicate('secure', "no")
#return
brain = os.path.join(var_dir, "%s.brn" % self.name)
if os.path.isfile(brain):
self.bot.bootstrap(brainFile=brain)
else:
for ai in os.listdir(aiml_dir):
if ai.endswith('aiml'):
self.bot.learn(os.path.join(aiml_dir, ai))
#self.bot.saveBrain(brain)
self.bot.setPredicate('secure', "no")
开发者ID:bithub,项目名称:bit.bot.aiml,代码行数:27,代码来源:ai.py
示例8: handleErrors
def handleErrors(self, writeError):
try:
yield
except exceptions.InvalidPathError as e:
writeError(str(e) or "invalid path", errcode=404,
jsonrpccode=JSONRPC_CODES['invalid_request'])
return
except exceptions.InvalidControlException as e:
writeError(str(e) or "invalid control action", errcode=501,
jsonrpccode=JSONRPC_CODES["method_not_found"])
return
except BadRequest as e:
writeError(str(e) or "invalid request", errcode=400,
jsonrpccode=JSONRPC_CODES["method_not_found"])
return
except BadJsonRpc2 as e:
writeError(e.message, errcode=400, jsonrpccode=e.jsonrpccode)
return
except Forbidden as e:
# There is nothing in jsonrc spec about forbidden error, so pick
# invalid request
writeError(
e.message, errcode=403, jsonrpccode=JSONRPC_CODES["invalid_request"])
return
except Exception as e:
log.err(_why='while handling API request')
writeError(repr(e), errcode=500,
jsonrpccode=JSONRPC_CODES["internal_error"])
return
开发者ID:Riziero,项目名称:buildbot,代码行数:29,代码来源:rest.py
示例9: encode_base64
def encode_base64(msg):
"""
Encode a non-multipart message's payload in Base64 (in place).
This method modifies the message contents in place and adds or replaces an
appropriate Content-Transfer-Encoding header.
:param msg: The non-multipart message to be encoded.
:type msg: email.message.Message
"""
encoding = msg.get('Content-Transfer-Encoding', None)
if encoding is not None:
encoding = encoding.lower()
# XXX Python's email module can only decode quoted-printable, base64 and
# uuencoded data, so we might have to implement other decoding schemes in
# order to support RFC 3156 properly and correctly calculate signatures
# for multipart attachments (eg. 7bit or 8bit encoded attachments). For
# now, if content is already encoded as base64 or if it is encoded with
# some unknown encoding, we just pass.
if encoding in [None, 'quoted-printable', 'x-uuencode', 'uue', 'x-uue']:
orig = msg.get_payload(decode=True)
encdata = _bencode(orig)
msg.set_payload(encdata)
# replace or set the Content-Transfer-Encoding header.
try:
msg.replace_header('Content-Transfer-Encoding', 'base64')
except KeyError:
msg['Content-Transfer-Encoding'] = 'base64'
elif encoding is not 'base64':
log.err('Unknown content-transfer-encoding: %s' % encoding)
开发者ID:bwagnerr,项目名称:leap_mail,代码行数:30,代码来源:rfc3156.py
示例10: callTargetSingle
def callTargetSingle(self,targetKey,*args,**kw):
'''call Target by Single
@param conn: client connection
@param targetKey: target ID
@param data: client data
'''
self._lock.acquire()
try:
target = self.getTarget(0)
if not target:
log.err('the command '+str(targetKey)+' not Found on service')
return None
if targetKey not in self.unDisplay:
log.msg("call method %s on service[single]"%target.__name__)
defer_data = target(targetKey,*args,**kw)
if not defer_data:
return None
if isinstance(defer_data,defer.Deferred):
return defer_data
d = defer.Deferred()
d.callback(defer_data)
finally:
self._lock.release()
return d
开发者ID:9miao,项目名称:Diablo-World,代码行数:25,代码来源:netapp.py
示例11: doReconfig
def doReconfig(self):
log.msg("beginning configuration update")
changes_made = False
failed = False
try:
# Run the master.cfg in thread, so that it cas use blocking code
new_config = yield threads.deferToThreadPool(
self.reactor, self.reactor.getThreadPool(),
self.config_loader.loadConfig)
changes_made = True
self.config = new_config
yield self.reconfigServiceWithBuildbotConfig(new_config)
except config.ConfigErrors as e:
for msg in e.errors:
log.msg(msg)
failed = True
except Exception:
log.err(failure.Failure(), 'during reconfig:')
failed = True
if failed:
if changes_made:
log.msg("WARNING: reconfig partially applied; master "
"may malfunction")
else:
log.msg("reconfig aborted without making any changes")
else:
log.msg("configuration update complete")
开发者ID:MPanH,项目名称:buildbot,代码行数:31,代码来源:master.py
示例12: _call_method
def _call_method(self, request):
"""Calls given method with given params and returns it value."""
method = self.method_data[request['method']]['method']
params = request['params']
result = None
try:
if isinstance(params, list):
# Does it have enough arguments?
if len(params) < self._man_args(method):
raise InvalidParamsError('not enough arguments')
# Does it have too many arguments?
if not self._vargs(method) \
and len(params) > self._max_args(method):
raise InvalidParamsError('too many arguments')
result = yield defer.maybeDeferred(method, *params)
elif isinstance(params, dict):
# Do not accept keyword arguments if the jsonrpc version is
# not >=1.1.
if request['jsonrpc'] < 11:
raise KeywordError
result = yield defer.maybeDeferred(method, **params)
else: # No params
result = yield defer.maybeDeferred(method)
except JSONRPCError:
raise
except Exception:
# Exception was raised inside the method.
log.msg('Exception raised while invoking RPC method "{}".'.format(
request['method']))
log.err()
raise ServerError
defer.returnValue(result)
开发者ID:joehillen,项目名称:txjason,代码行数:35,代码来源:service.py
示例13: _validate_expectation
def _validate_expectation(self, exp, command):
got = (command.remote_command, command.args)
for child_exp in exp.nestedExpectations():
try:
yield self._validate_expectation(child_exp, command)
exp.expectationPassed(exp)
except AssertionError as e:
# log this error, as the step may swallow the AssertionError or
# otherwise obscure the failure. Trial will see the exception in
# the log and print an [ERROR]. This may result in
# double-reporting, but that's better than non-reporting!
log.err()
exp.raiseExpectationFailure(child_exp, e)
if exp.shouldAssertCommandEqualExpectation():
# handle any incomparable args
for arg in exp.incomparable_args:
self.assertTrue(arg in got[1],
"incomparable arg '%s' not received" % (arg,))
del got[1][arg]
# first check any ExpectedRemoteReference instances
exp_tup = (exp.remote_command, exp.args)
if exp_tup != got:
_describe_cmd_difference(exp, command)
raise AssertionError(
"Command contents different from expected; see logs")
if exp.shouldRunBehaviors():
# let the Expect object show any behaviors that are required
yield exp.runBehaviors(command)
开发者ID:opalmer,项目名称:buildbot,代码行数:32,代码来源:steps.py
示例14: LOG_ERR
def LOG_ERR(msg):
"""
Abstraction method for logging errors.
@type msg: C{str}
@param msg: a error message to be logged.
"""
log.err('[error]\t{0}'.format(msg))
开发者ID:FirstCypress,项目名称:LiV,代码行数:7,代码来源:i2c.py
示例15: join_stage
def join_stage(self, stage_ID):
"""Connects the client to a stage automatically leaving the last one
(if any, which is currently barely possible)
requires stage ID in factory.stages.
Returns self.stage, which will be None if no join has succeeded."""
newstage = self.factory.stages.get(stage_ID, None)
if newstage is not None:
if self.stage is not None:
self.stage.drop_socket(self)
newstage.add_socket(self)
self.stage = newstage
# Send full stage name to the client
self.send("STAGE_NAME", stageName=newstage.name, stageID=newstage.ID)
if self.player is self.factory.audience:
self.modes = self.audience_modes
else:
self.modes = self.player_modes
"""
if newstage.isPlayerAudience(self.player) is True:
self.modes = self.audience_modes
else:
self.modes = self.player_modes
"""
else: # stage doesn't exist
log.err("tried to join missing stage ('%s'). can't do that." % stage_ID)
return self.stage
开发者ID:foobarlab,项目名称:UpStage-Video-Hack,代码行数:30,代码来源:server.py
示例16: proxy
def proxy():
try:
assert self.session
return fn(self.session, *args, **kwargs)
except:
log.err()
raise
开发者ID:opencv-infrastructure,项目名称:common-pullrequest-plugin,代码行数:7,代码来源:database.py
示例17: _fail
def _fail(self, reason, request):
"""
"""
log.err('EngineSessionAdapter fail %s' % reason)
result = json.dumps({'status':'ERR', 'response':str(reason)})
request.write(result)
request.finish()
开发者ID:thebookworm101,项目名称:codenode,代码行数:7,代码来源:core.py
示例18: taskFailed
def taskFailed(self, reason):
# reason = TaskFailure
errorMail = reason.mail.reply()
errorTask = reason.task
allTasks = reason.tasks
results = reason.results
format = reason.format
errorIndex = allTasks.index(errorTask)
error_nr = getattr(reason.value, 'ERRNO', 8002)
# Create a Fault struct
fault = {
'faultCode': error_nr,
'faultString': reason.getErrorMessage(),
}
all_results = list(results)
all_results.append(fault)
xml_attachment = None
body = ""
try:
xml_attachment = iapplicationservermailmessage.XmlAttachment(all_results, RESULT_ATTACHMENT_FILENAME)
except ValueError, ex:
msg = "Could not attach results to reply mail."
log.err(msg)
log.err(ex)
body += msg
开发者ID:racktivity,项目名称:ext-pylabs-core,代码行数:27,代码来源:transport.py
示例19: appengineIncomming
def appengineIncomming(self, payload):
if payload["p"] == "http":
self.sendCallbackViaHTTP(payload)
elif payload["p"] == "xmpp":
self.sendCallbackViaXMPP(payload)
else:
log.err("Unknown callback protocol: %s" % payload["p"])
开发者ID:rogerthat-platform,项目名称:rogerthat-kickserver,代码行数:7,代码来源:callbackec.py
示例20: handleError
def handleError():
from twisted.python import failure
global exitStatus
exitStatus = 2
log.err(failure.Failure())
reactor.stop()
raise
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:7,代码来源:ckeygen.py
注:本文中的twisted.python.log.err函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论