当前位置: 首页>>代码示例>>Python>>正文


Python Anomos.LOG类代码示例

本文整理汇总了Python中Anomos.LOG的典型用法代码示例。如果您正苦于以下问题:Python LOG类的具体用法?Python LOG怎么用?Python LOG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LOG类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _close

    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)
开发者ID:Miserlou,项目名称:Anomos,代码行数:28,代码来源:download.py

示例2: socket_cb

 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))
开发者ID:Miserlou,项目名称:Anomos,代码行数:26,代码来源:NeighborManager.py

示例3: _check

 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()
开发者ID:Miserlou,项目名称:Anomos,代码行数:33,代码来源:Rerequester.py

示例4: connection_completed

 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()
开发者ID:Miserlou,项目名称:Anomos,代码行数:7,代码来源:Relayer.py

示例5: got_have

 def got_have(self, message):
     i = toint(message[1:])
     if i >= self.torrent.numpieces:
         log.error("Piece index out of range")
         self.fatal_error()
         return
     self.download.got_have(i)
开发者ID:Miserlou,项目名称:Anomos,代码行数:7,代码来源:AnomosEndPointProtocol.py

示例6: _scrape

 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)
开发者ID:Miserlou,项目名称:Anomos,代码行数:32,代码来源:Rerequester.py

示例7: read_header

 def read_header(self, data):
     data = data.strip()
     if data == '':
         # check for Accept-Encoding: header, pick a
         if self.headers.has_key('accept-encoding'):
             ae = self.headers['accept-encoding']
             log.debug("Got Accept-Encoding: " + ae + "\n")
         else:
             #identity assumed if no header
             ae = 'identity'
         # this eventually needs to support multple acceptable types
         # q-values and all that fancy HTTP crap
         # for now assume we're only communicating with our own client
         if ae.find('gzip') != -1:
             self.encoding = 'gzip'
         else:
             #default to identity.
             self.encoding = 'identity'
         r = self.getfunc(self, self.path, self.headers)
         if r is not None:
             self.answer(r)
             return None
     try:
         i = data.index(':')
     except ValueError:
         return None
     self.headers[data[:i].strip().lower()] = data[i+1:].strip()
     log.debug(data[:i].strip() + ": " + data[i+1:].strip())
     return self.read_header
开发者ID:Miserlou,项目名称:Anomos,代码行数:29,代码来源:HTTPS.py

示例8: handle_error

 def handle_error(self):
     t, v, tb = sys.exc_info()
     if isinstance(v, KeyboardInterrupt):
         raise
     else:
         log.info(traceback.format_exc())
         self.close()
开发者ID:Miserlou,项目名称:Anomos,代码行数:7,代码来源:Dispatcher.py

示例9: get_ctx

 def get_ctx(self, allow_unknown_ca=False, req_peer_cert=True, session=None):
     ctx = SSL.Context("sslv23")
     # Set certificate and private key
     m2.ssl_ctx_use_x509(ctx.ctx, self.cert.x509)
     m2.ssl_ctx_use_rsa_privkey(ctx.ctx, self.rsakey.rsa)
     if not m2.ssl_ctx_check_privkey(ctx.ctx):
         raise CryptoError('public/private key mismatch')
     # Ciphers/Options
     ctx.set_cipher_list(CIPHER_SET)
     ctx.set_options(CTX_OPTIONS)
     # CA settings
     cloc = os.path.join(global_certpath, 'cacert.root.pem')
     if ctx.load_verify_locations(cafile=cloc) != 1:
         log.error("Problem loading CA certificates")
         raise CryptoError('CA certificates not loaded')
     # Verification
     cb = mk_verify_cb(allow_unknown_ca=allow_unknown_ca)
     CTX_V_FLAGS = SSL.verify_peer
     if req_peer_cert:
         CTX_V_FLAGS |= SSL.verify_fail_if_no_peer_cert
     ctx.set_verify(CTX_V_FLAGS,3,cb)
     # Session
     if session:
         ctx.set_session_id_ctx(session)
     return ctx
开发者ID:Miserlou,项目名称:Anomos,代码行数:25,代码来源:_Certificate.py

示例10: got_tcode

 def got_tcode(self, message):
     tcreader = TCReader(self.manager.certificate)
     try:
         tcdata = tcreader.parseTC(message[1:])
     except Anomos.Crypto.CryptoError, e:
         log.error("Decryption Error: %s" % str(e))
         self.socket.close()
         return
开发者ID:Miserlou,项目名称:Anomos,代码行数:8,代码来源:AnomosNeighborProtocol.py

示例11: found_terminator

 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)
开发者ID:Miserlou,项目名称:Anomos,代码行数:8,代码来源:HTTPS.py

示例12: _load_fastresume

 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))
开发者ID:Miserlou,项目名称:Anomos,代码行数:8,代码来源:StorageWrapper.py

示例13: __init__

 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)
开发者ID:Miserlou,项目名称:Anomos,代码行数:8,代码来源:GUI.py

示例14: close

 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()
开发者ID:Miserlou,项目名称:Anomos,代码行数:8,代码来源:EndPoint.py

示例15: send_tracking_code

 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)
开发者ID:Miserlou,项目名称:Anomos,代码行数:9,代码来源:AnomosRelayerProtocol.py


注:本文中的Anomos.LOG类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。