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


Python Params类代码示例

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


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

示例1: display_msg

def display_msg(msg, status = None, color = None):
	Configure.g_maxlen = max(Configure.g_maxlen, len(msg))
	if status:
		print "%s :" % msg.ljust(Configure.g_maxlen),
		Params.pprint(color, status)
	else:
		print "%s" % msg.ljust(Configure.g_maxlen)
开发者ID:lxlxlo,项目名称:composite-devel,代码行数:7,代码来源:autowaf.py

示例2: __init__

 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,代码行数:31,代码来源:Cache.py

示例3: get_backend

def get_backend(main=True):
    global backend
    if main:
        if not backend:
            backend = Params.descriptor_storage_type(Params.RESOURCES)
        return backend
    return Params.descriptor_storage_type(Params.RESOURCES, 'r') 
开发者ID:dotmpe,项目名称:htcache,代码行数:7,代码来源:Resource.py

示例4: send

    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,代码行数:27,代码来源:Response.py

示例5: init

 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,代码行数:26,代码来源:caches.py

示例6: __init__

 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,代码行数:8,代码来源:caches.py

示例7: close

 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,代码行数:9,代码来源:caches.py

示例8: open_partial

 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,代码行数:9,代码来源:caches.py

示例9: prepare_nocache_response

 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,代码行数:9,代码来源:Protocol.py

示例10: rewrite

 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,代码行数:9,代码来源:Rules.py

示例11: display_msg

def display_msg(msg, status = None, color = None):
    sr = msg
    global g_maxlen
    g_maxlen = max(g_maxlen, len(msg))
    if status:
        print "%s :" % msg.ljust(g_maxlen),
        Params.pprint(color, status)
    else:
        print "%s" % msg.ljust(g_maxlen)
开发者ID:XelaRellum,项目名称:zyn,代码行数:9,代码来源:lv2plugin.py

示例12: connect

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,代码行数:9,代码来源:Protocol.py

示例13: __handle_size

 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,代码行数:10,代码来源:Protocol.py

示例14: run

 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,代码行数:11,代码来源:Rules.py

示例15: step

 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,代码行数:11,代码来源:fiber.py


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