本文整理汇总了Python中Anomos.LOG.info方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.info方法的具体用法?Python LOG.info怎么用?Python LOG.info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Anomos.LOG
的用法示例。
在下文中一共展示了LOG.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _close
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def _close(self):
if self.closed:
return
self.closed = True
# GTK Crash Hack
import time
time.sleep(0.2)
self.event_handler.remove_context(self)
self._doneflag.set()
log.info("Closing connections, please wait...")
if self._announced:
self._rerequest.announce_stop()
self._rerequest.cleanup()
if self._hashcheck_thread is not None:
self._hashcheck_thread.join() # should die soon after doneflag set
if self._myfiles is not None:
self._filepool.remove_files(self._myfiles)
if self._listening:
self.neighbors.remove_torrent(self.infohash)
for port in self.reserved_ports:
self._singleport_listener.release_port(port)
if self._storage is not None:
self._storage.close()
self.schedule(0, gc.collect)
示例2: socket_cb
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def socket_cb(self, sock):
""" Called by P2PConnection after connect() has completed """
if sock.connected:
log.info('Connected to %s' %str(sock.addr))
for id,v in self.incomplete.iteritems():
if v == sock.addr:
break
else:
return #loc wasn't found
AnomosNeighborInitializer(self, sock, id)
else:
#Remove nid,loc pair from incomplete
torm = []
for k,v in self.incomplete.items():
if v == sock.addr:
log.info('Failed to connect, discarding \\x%02x' % ord(k))
torm.append(k)
for j in torm:
self.rm_neighbor(j)
if sock.addr == None:
if self.incomplete.items() != []:
log.info("Remaining incomplete peers: %d" %len(self.incomplete.items()))
else:
log.info("No remaining incomplete peers")
else:
log.info("Failed to open connection to %s\n" % str(sock.addr))
示例3: handle_error
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def handle_error(self):
t, v, tb = sys.exc_info()
if isinstance(v, KeyboardInterrupt):
raise
else:
log.info(traceback.format_exc())
self.close()
示例4: connection_completed
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def connection_completed(self):
log.info("Relay connection [%02x:%d] established" %
(int(ord(self.neighbor.id)),self.stream_id))
self.complete = True
self.flush_pre_buffer()
self.orelay.complete = True
self.orelay.flush_pre_buffer()
示例5: close
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [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()
示例6: found_terminator
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def found_terminator(self):
creq = self.req
self.req = ''
if not self.next_func:
log.info("Malformed request from %s:%d" % self.socket.addr)
self.handle_close()
return
self.next_func = self.next_func(creq)
示例7: send_tracking_code
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def send_tracking_code(self, trackcode):
#XXX: Just a test, Throw tcodes into the PMQ instead of sending them
# immediately
#self.network_ctl_msg(TCODE, trackcode)
log.info("Queuing tracking code")
self.neighbor.queue_message(self.stream_id, TCODE+trackcode)
if self.next_upload is None:
log.info("Queuing self")
self.ratelimiter.queue(self)
示例8: close
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [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()
示例9: _parsepeers
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def _parsepeers(self, p):
peers = []
if type(p) == str:
for x in xrange(0, len(p), 6):
ip = '.'.join([str(ord(i)) for i in p[x:x+4]])
log.info("Got peer %s"%ip)
port = (ord(p[x+4]) << 8) | ord(p[x+5])
peers.append((ip, port, None))
else:
for x in p:
log.info("Got peer %s"%str(x['ip']))
peers.append((x['ip'], x['port'], x.get('nid')))
return peers
示例10: connection_completed
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def connection_completed(self, socket, id):
"""Called by AnomosNeighborInitializer"""
if self.incomplete.has_key(id):
del self.incomplete[id]
if id == NAT_CHECK_ID:
log.info("NAT check ok.")
return
self.add_neighbor(socket, id)
tasks = self.waiting_tcs.get(id)
if tasks is None:
return
for task in tasks:
#TODO: Would a minimum wait between these tasks aid anonymity?
self.schedule(0, task)
del self.waiting_tcs[id]
示例11: start_endpoint_stream
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def start_endpoint_stream(self, torrent, aeskey, data=None):
""" Starts an EndPoint stream
@param torrent: Torrent to be uploaded/downloaded
@param aeskey: AES-256 key to be used for transfer communication
@param data: Tracking Code to be sent
@type torrent: Anomos.Torrent.Torrent
@type aeskey: Anomos.crypto.AESKey
@type data: String
@return: Newly created EndPoint object"""
if data is None: # Incoming stream
nxtid = self.incoming_stream_id
self.next_stream_id = nxtid + 1
else: # Localy initialized stream
nxtid = self.next_stream_id
self.next_stream_id += 1
self.streams[nxtid] = \
EndPoint(nxtid, self, torrent, aeskey, data)
self.manager.schedule(180, self.streams[nxtid].completion_timeout)
log.info("Starting endpoint")
return self.streams[nxtid]
示例12: _rerequest
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def _rerequest(self, query):
""" Make an HTTP GET request to the tracker
Note: This runs in its own thread.
"""
log.info("Making announce to " + self.url + ":" + str(self.remote_port))
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.path, query)
h.putrequest('GET', s)
# I suggest that for now, until there is a better solution in python,
# that connections with socks proxies be done with:
# socat TCP4-LISTEN:5555,fork SOCKS4A:s,socksport=9050
# or use Privoxy:
# 127.0.0.1:8118
else:
#No proxy url, use normal connection
h = HTTPSConnection(self.url, self.remote_port, ssl_context=self.ssl_ctx)
h.putrequest('GET', self.path+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)
示例13: __init__
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def __init__(self, stream_id, neighbor, torrent, aes, data=None):
AnomosEndPointProtocol.__init__(self)
self.partial_recv = ''
self.sent_break = False
self.stream_id = stream_id
self.neighbor = neighbor
self.manager = neighbor.manager
self.ratelimiter = neighbor.ratelimiter
self.torrent = torrent
self.e2e_key = aes
self.complete = False
self.closed = False
self.choker = None
self.choke_sent = False
self.upload = None
self.next_upload = None
if data is not None:
self.send_tracking_code(data)
else:
self.send_confirm()
self.connection_completed()
log.info("Sent confirm")
示例14: _start_download
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def _start_download(self, metainfo, feedback, save_path):
# GTK Crash Hack
import time
time.sleep(0.2)
self.feedback = feedback
self._set_auto_uploads()
self.infohash = metainfo.infohash
self.file_size = metainfo.file_size
if not metainfo.reported_errors:
metainfo.show_encoding_errors(log.error)
if metainfo.is_batch:
myfiles = [os.path.join(save_path, f) for f in metainfo.files_fs]
else:
myfiles = [save_path]
self._filepool.add_files(myfiles, self)
self._myfiles = myfiles
self._storage = Storage(self.config, self._filepool, zip(myfiles, metainfo.sizes))
resumefile = None
if self.config["data_dir"]:
filename = os.path.join(self.config["data_dir"], "resume", self.infohash.encode("hex"))
if os.path.exists(filename):
try:
resumefile = file(filename, "rb")
if self._storage.check_fastresume(resumefile) == 0:
resumefile.close()
resumefile = None
except Exception, e:
log.info("Could not load fastresume data: " + str(e) + ". Will perform full hash check.")
if resumefile is not None:
resumefile.close()
resumefile = None
示例15: send_break
# 需要导入模块: from Anomos import LOG [as 别名]
# 或者: from Anomos.LOG import info [as 别名]
def send_break(self):
log.info("breaking %s" % str(self))
self.network_ctl_msg(BREAK)
self.sent_break = True