本文整理汇总了Python中Anomos.LOG.warning方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.warning方法的具体用法?Python LOG.warning怎么用?Python LOG.warning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Anomos.LOG
的用法示例。
在下文中一共展示了LOG.warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _check
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def _check(self):
if self.current_started is not None:
if self.current_started <= bttime() - 58:
log.warning("Tracker announce still not complete "
"%d seconds after starting it" %
int(bttime() - self.current_started))
## Announce has been hanging for too long, retry it.
if int(bttime() - self.current_started) >= 180:
self._announce(STARTED)
return
if self.basequery is None:
self.basequery = self._makequery()
self._announce(STARTED)
return
if self.changed_port:
self._announce(STOPPED)
self.changed_port = False
self.basequery = None
return
if self.finish:
self.finish = False
self._announce(COMPLETED)
return
if self.fail_wait is not None:
if self.last_time + self.fail_wait <= bttime():
self._announce(STARTED)
return
if self.last_time > bttime() - self.config['rerequest_interval']:
return
getmore = bool(self.neighbors.failed_connections())
#TODO: also reannounce when TCs have failed
if getmore or bttime() - self.last_time > self.announce_interval:
self._announce()
示例2: _scrape
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def _scrape(self, query):
""" Make an HTTP GET request to the tracker
Note: This runs in its own thread.
"""
self.spath = "/scrape"
if not self.https:
log.warning("Warning: Will not connect to non HTTPS server")
return
try:
if self.proxy_url:
h = ProxyHTTPSConnection(self.proxy_url, \
username=self.proxy_username, \
password=self.proxy_password, \
ssl_context=self.ssl_ctx)
s = "https://%s:%d%s%s" % (self.url, self.remote_port, self.spath, query)
h.putrequest('GET', s)
else:
#No proxy url, use normal connection
h = HTTPSConnection(self.url, self.remote_port, ssl_context=self.ssl_ctx)
h.putrequest('GET', self.spath+query)
h.endheaders()
resp = h.getresponse()
data = resp.read()
resp.close()
h.close()
h = None
# urllib2 can raise various crap that doesn't have a common base
# exception class especially when proxies are used, at least
# ValueError and stuff from httplib
except Exception, g:
def f(r='Problem connecting to ' + self.url + ': ' + str(g)):
self._postrequest(errormsg=r)
示例3: __init__
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def __init__(self, *args):
apply(gtk.Window.__init__, (self,)+args)
try:
#TODO: Icon doesn't work on XP build, don't know why
if (os.name != 'nt'):
self.set_icon_from_file(os.path.join(image_root,'anomos.ico'))
except Exception, e:
log.warning(e)
示例4: close
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def close(self):
if self.closed:
log.warning("Double close")
return
log.info("Closing %s"%self.uniq_id())
if self.complete:
self.send_break()
self.shutdown()
示例5: _load_fastresume
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def _load_fastresume(self, resumefile, typecode):
if resumefile is not None:
try:
r = array(typecode)
r.fromfile(resumefile, self.numpieces)
return r
except Exception, e:
log.warning("Couldn't read fastresume data: " + str(e))
示例6: ore_closed
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def ore_closed(self):
""" Closes the connection when a Break has been received by our
other relay (ore). Called by this object's ore during
shutdown """
if self.closed:
log.warning("Double close")
return
if not self.sent_break:
self.send_break()
示例7: close
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def close(self):
# Connection was closed locally (as opposed to
# being closed by receiving a BREAK message)
if self.closed:
log.warning("%s: Double close" % self.uniq_id())
return
log.info("Closing %s"%self.uniq_id())
if self.complete and not self.sent_break:
self.send_break()
self.shutdown()
示例8: start_circuit
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def start_circuit(self, tc, infohash, aeskey):
"""Called from Rerequester to initialize new circuits we've
just gotten TCs for from the Tracker"""
if self.count_streams() >= self.config['max_initiate']:
log.warning("Not starting circuit -- Stream count exceeds maximum")
return
tcreader = TCReader(self.certificate)
try:
tcdata = tcreader.parseTC(tc)
except Anomos.Crypto.CryptoError, e:
log.error("Decryption Error: %s" % str(e))
return
示例9: connection_completed
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def connection_completed(self):
""" Called when a CONFIRM message is received
indicating that our peer has received our
tracking code """
if self.complete:
log.warning("Double complete")
return
self.complete = True
self.upload = self.torrent.make_upload(self)
self.choker = self.upload.choker
self.choker.connection_made(self)
self.download = self.torrent.make_download(self)
self.torrent.add_active_stream(self)
示例10: shutdown
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def shutdown(self):
if self.closed:
log.warning("Double close")
return
self.closed = True
if not (self.decremented_count or
(self.orelay and self.orelay.decremented_count)):
self.manager.dec_relay_count()
self.decremented_count = True
# Tell our orelay to close.
if self.orelay and not self.orelay.closed:
self.orelay.ore_closed()
self.ratelimiter.clean_closed()
示例11: socket_cb
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def socket_cb(self, sock):
if sock.connected:
peercert = self.socket.get_peer_cert()
recvd_pid = peercert.get_fingerprint('sha256')[-20:]
if self.peerid != recvd_pid:
# The certificate we received doesn't match the one
# given to the tracker.
# XXX: Should probably disconnect the peer rather than
# just saying the NatCheck failed.
log.warning("Peer certificate mismatch")
self.answer(False)
AnomosNeighborInitializer(self, self.socket, self.id)
else:
self.answer(False)
示例12: _postrequest
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def _postrequest(self, data=None, errormsg=None):
self.current_started = None
self.last_time = bttime()
if errormsg is not None:
log.warning(errormsg)
self._fail()
return
try:
# Here's where we receive/decrypt data from the tracker
r = bdecode(data)
check_peers(r)
except BTFailure, e:
if data != '':
log.error('bad data from tracker - ' + str(e))
self._fail()
return
示例13: update_neighbor_list
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def update_neighbor_list(self, list):
freshids = dict([(i[2],(i[0],i[1])) for i in list]) #{nid : (ip, port)}
# Remove neighbors not found in freshids
for id in self.neighbors.keys():
if not freshids.has_key(id):
self.rm_neighbor(id)
# Start connections with the new neighbors
for id, loc in freshids.iteritems():
if self.nid_collision(id, loc):
# Already had neighbor by the given id at a different location
log.warning('NID collision - x%02x' % ord(id))
# To be safe, kill connection with the neighbor we already
# had with the requested ID and add ID to the failed list
self.rm_neighbor(id)
elif (not self.has_neighbor(id)) and (id not in self.failedPeers):
self.start_connection(id, loc)
示例14: start_connection
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def start_connection(self, id, loc):
""" Start a new SSL connection to the peer at loc and
assign them the NeighborID id
@param loc: (IP, Port)
@param id: The neighbor ID to assign to this connection
@type loc: tuple
@type id: int """
if self.config['one_connection_per_ip'] and self.has_ip(loc[0]):
log.warning('Got duplicate IP address in neighbor list. ' \
'Multiple connections to the same IP are disabled ' \
'in your config.')
return
self.incomplete[id] = loc
conn = P2PConnection(addr=loc,
ssl_ctx=self.ssl_ctx,
connect_cb=self.socket_cb,
schedule=self.schedule)
示例15: _load
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import warning [as 别名]
def _load(self):
"""Attempts to load the certificate and key from self.certfile and self.keyfile,
Generates the certificate and key if they don't exist"""
if not self.secure:
self.rsakey = RSA.load_key(self.keyfile, m2util.no_passphrase_callback)
else:
# Allow 3 attempts before quitting
i = 0
while i < 3:
try:
self.rsakey = RSA.load_key(self.keyfile)
break
except RSA.RSAError:
i += 1
else:
log.warning("\nInvalid password entered, exiting.")
sys.exit()
self.cert = X509.load_cert(self.certfile)