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


Python Params.log方法代码示例

本文整理汇总了Python中Params.log方法的典型用法代码示例。如果您正苦于以下问题:Python Params.log方法的具体用法?Python Params.log怎么用?Python Params.log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Params的用法示例。


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

示例1: __init__

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
 def __init__(self, path=None):
     """
     The path is an `wget -r` path. Meaning it has the parts:
     host/path?query. The cache implementation will determine the final
     local path name. 
     """
     super(File, self).__init__()
     os.chdir(Params.ROOT)
     if path:
         rpath = self.apply_rules(path)
         self.init(rpath)
         # symlink to rewritten path
         # if path != rpath and not os.path.exists(path):
         #    Params.log("Symlink: %s -> %s" %(path, rpath))
         #    os.makedirs(os.path.dirname(path))
         #    os.symlink(rpath, path)
         # check if target is symlink, must exist
         if os.path.islink(rpath):
             target = os.readlink(rpath)
             if not os.path.exists(target):
                 Params.log("Warning: broken symlink, replacing: %s" % target)
                 os.unlink(rpath)
         # check if target is partial, rename
         i = 1
         if os.path.exists(rpath + Params.PARTIAL):
             while os.path.exists("%s.%s%s" % (rpath, i, Params.PARTIAL)):
                 i += 1
             shutil.copyfile(rpath + Params.PARTIAL, "%s.%s%s" % (rpath, i, Params.PARTIAL))
             Params.log("Warning: backed up duplicate incomplete %s" % i)
             # XXX: todo: keep largest partial only
         assert len(self.path) < 255, "LBYL, cache location path to long for Cache.File! "
开发者ID:dotmpe,项目名称:htcache,代码行数:33,代码来源:Cache.py

示例2: send

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
    def send( self, sock ):

        assert not self.Done
        if self.__sendbuf:
            bytecnt = sock.send( self.__sendbuf )
            self.__sendbuf = self.__sendbuf[ bytecnt: ]
        else:
            bytecnt = Params.MAXCHUNK
            if 0 <= self.__end < self.__pos + bytecnt:
                bytecnt = self.__end - self.__pos

            chunk = self.__protocol.read( self.__pos, bytecnt )
            if self.__protocol.rewrite:
                delta, chunk = Rules.Rewrite.run(chunk)
                self.__protocol.size += delta
            try:
                self.__pos += sock.send( chunk )
            except:
                Params.log("Error writing to client, aborted!")
                self.Done = True
                # Unittest 2: keep partial file 
                #if not self.__protocol.cache.full():
                #    self.__protocol.cache.remove_partial()
                return
        self.Done = not self.__sendbuf and ( 
                self.__pos >= self.__protocol.size >= 0 
                or self.__pos >= self.__end >= 0 )
开发者ID:dotmpe,项目名称:htcache,代码行数:29,代码来源:Response.py

示例3: init

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
 def init(self, path):
     Params.log("FileTreeQH.init %r" % path, 5)
     # encode query if present
     sep = path.find( '?' )
     # other encoding in query/fragment part        
     if sep != -1:
         if '&' in path[sep:]:
             qsep='&'
             parts = path[sep:].split('&')
         elif ';' in path[sep:]:
             qsep=';'
             parts = path[sep:].split(';')
         else:
             qsep=''
             parts = [path[sep:]]
         parts.sort()   
         path = path[ :sep ] + os.sep + '#' + md5(qsep.join(parts)).hexdigest()
     # optional removal of directories in entire path
     psep = Params.ENCODE_PATHSEP
     if psep:
         path = path.replace( '/', psep)
     # make archive path    
     if Params.ARCHIVE:
         path = time.strftime( Params.ARCHIVE, time.gmtime() ) + path 
     self.path = os.path.join(Params.ROOT, path)
     self.file = None
开发者ID:dotmpe,项目名称:htcache,代码行数:28,代码来源:caches.py

示例4: __init__

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
 def __init__(self, path):
     Params.log("RefHash.__init__ %r" % path, 5)
     super(RefHash, self).__init__(path)
     self.refhash = md5(path).hexdigest()
     self.path = Params.ROOT + self.refhash
     self.file = None
     if not os.path.exists(Params.ROOT + Params.PARTIAL):
         os.mkdir(Params.ROOT + Params.PARTIAL)
开发者ID:dotmpe,项目名称:htcache,代码行数:10,代码来源:caches.py

示例5: open_partial

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
 def open_partial(self, offset=-1):
     self.path = Params.ROOT + Params.PARTIAL + os.sep + self.refhash
     self.mtime = os.stat( self.path ).st_mtime
     self.file = open( self.path, 'a+' )
     if offset >= 0:
         assert offset <= self.tell(), 'range does not match file in cache'
         self.file.seek( offset )
         self.file.truncate()
     Params.log('Resuming partial file in cache at byte %i' % self.tell(), 2)
开发者ID:dotmpe,项目名称:htcache,代码行数:11,代码来源:caches.py

示例6: rewrite

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
 def rewrite(klass, pathref):
     if Params.JOIN:
         for pattern, regex, repl in Params.JOIN:
             m = regex.match(pathref)
             if m:
                 capture = True
                 pathref = regex.sub(repl, pathref)
                 Params.log("Joined URL matching rule %r" % pattern, threshold=1)
     return pathref
开发者ID:dotmpe,项目名称:htcache,代码行数:11,代码来源:Rules.py

示例7: prepare_nocache_response

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
 def prepare_nocache_response(self):
     "Blindly respond for NoCache rule matches. "
     for pattern, compiled in Params.NOCACHE:
         p = self.requri.find(':') # split scheme
         if compiled.match(self.requri[p+3:]):
             Params.log('Not caching request, matches pattern: %r.' %
                 pattern)
             self.Response = Response.BlindResponse
             return True
开发者ID:dotmpe,项目名称:htcache,代码行数:11,代码来源:Protocol.py

示例8: connect

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
def connect( addr ):
    assert Params.ONLINE, 'operating in off-line mode'
    if addr not in DNSCache:
        Params.log('Requesting address info for %s:%i' % addr, 2)
        try:
            DNSCache[ addr ] = socket.getaddrinfo(
                addr[ 0 ], addr[ 1 ], Params.FAMILY, socket.SOCK_STREAM )
        except Exception, e:
            raise DNSLookupException(addr, e)
开发者ID:dotmpe,项目名称:htcache,代码行数:11,代码来源:Protocol.py

示例9: close

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
 def close( self ):
     self.path = Params.ROOT + Params.PARTIAL + os.sep + self.refhash
     size = self.tell()
     self.file.close()
     if self.mtime >= 0:
         os.utime( self.path, ( self.mtime, self.mtime ) )
     if self.size == size:
         os.rename( self.path, Params.ROOT + self.refhash )
         Params.log('Finalized %s' % self.path, 2)
开发者ID:dotmpe,项目名称:htcache,代码行数:11,代码来源:caches.py

示例10: __handle_size

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
 def __handle_size( self, code, line ):
     if code == 550:
         self.Response = Response.NotFoundResponse
         return
     assert code == 213,\
         'server sends %i; expected 213 (file status)' % code
     self.size = int( line )
     Params.log('File size: %s' % self.size)
     self.__sendbuf = 'MDTM %s\r\n' % self.__path
     self.__handle = FtpProtocol.__handle_mtime
开发者ID:dotmpe,项目名称:htcache,代码行数:12,代码来源:Protocol.py

示例11: run

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
 def run(klass, chunk):
     delta = 0
     Params.log("Trying to rewrite chunk. ", 3)
     for regex, repl in Params.REWRITE:
         if regex.search(chunk):
             new_chunk, count = regex.subn(repl, chunk)
             delta += len(new_chunk)-len(chunk)
             chunk = new_chunk
         else:
             Params.log("No match on chunk", 4)
     return delta, chunk
开发者ID:dotmpe,项目名称:htcache,代码行数:13,代码来源:Rules.py

示例12: step

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
 def step( self, throw=None ):
     stdout = sys.stdout
     stderr = sys.stderr
     try:
         sys.stdout = sys.stderr = self
         Fiber.step( self, throw )
         if self.state:
             Params.log('Waiting at %s'% self, 1)
     finally:
         sys.stdout = stdout
         sys.stderr = stderr
开发者ID:dotmpe,项目名称:htcache,代码行数:13,代码来源:fiber.py

示例13: recv

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
    def recv( self, sock ):
        assert not self.hasdata()

        chunk = sock.recv( Params.MAXCHUNK )
        assert chunk, 'server closed connection prematurely'
        self.__recvbuf += chunk
        while '\n' in self.__recvbuf:
            reply, self.__recvbuf = self.__recvbuf.split( '\n', 1 )
            Params.log('S: %s' % reply.rstrip(), 2)
            if reply[ :3 ].isdigit() and reply[ 3 ] != '-':
                self.__handle( self, int( reply[ :3 ] ), reply[ 4: ] )
                Params.log('C: %s' % self.__sendbuf.rstrip(), 2)
开发者ID:dotmpe,项目名称:htcache,代码行数:14,代码来源:Protocol.py

示例14: get_cache

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
def get_cache(hostinfo, req_path):
    """
    req_path is a URL path ref including query-part,
    the backend will determine real cache location
    """
    # Prepare default cache location
    cache_location = '%s:%i/%s' % (hostinfo + (req_path,))
    cache_location = cache_location.replace(':80', '')
    cache = Cache.load_backend_type(Params.CACHE)(cache_location)
    Params.log("Init cache: %s %s" % (Params.CACHE, cache), 3)
    Params.log('Prepped cache, position: %s' % cache.path, 2)
# XXX: use unrewritten path as descriptor key, need unique descriptor per resource
    cache.descriptor_key = cache_location
    return cache
开发者ID:dotmpe,项目名称:htcache,代码行数:16,代码来源:Resource.py

示例15: __init__

# 需要导入模块: import Params [as 别名]
# 或者: from Params import log [as 别名]
    def __init__( self, request ):
        super(FtpProtocol, self).__init__( request )

        if Params.STATIC and self.cache.full():
          self.__socket = None
          Params.log("Static FTP cache : %s" % self.requri)
          self.cache.open_full()
          self.Response = Response.DataResponse
          return

        self.__socket = connect(request.hostinfo)
        self.__path = request.Resource.ref.path
        self.__path_old = request.envelope[1] # XXX
        self.__sendbuf = ''
        self.__recvbuf = ''
        self.__handle = FtpProtocol.__handle_serviceready
开发者ID:dotmpe,项目名称:htcache,代码行数:18,代码来源:Protocol.py


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