def _readServer(contents): """Read a ServerInfo from the string 'contents', which is either a server descriptor or the name of a file holding a descriptor. Raise MixError on failure.""" if stringContains(contents, "[Server]"): pass else: contents = readPossiblyGzippedFile(contents) # May raise ConfigError, MixError return contents, ServerInfo(string=contents, assumeValid=0)
def _moveServer(directory1, directory2, fname): """Move a server contained in directory1/fname into directory2, chosing a new name for it as needed, and avoiding duplicates.""" fname1 = os.path.join(directory1, fname) if "-" in fname: nn = fname[:fname.find("-")] else: nn = "UNKNOWN" s = readPossiblyGzippedFile(fname1) _writeServer(directory2, s, nn) os.unlink(fname1)
def __init__(self, string=None, fname=None, validatedDigests=None, _keepServerContents=0): """DOCDOC raises ConfigError. """ if string: contents = string else: try: contents = readPossiblyGzippedFile(fname) except (IOError, zlib.error), e: raise ConfigError("Couldn't decompress %s: %s"%(fname,e))
def __init__(self, string=None, fname=None, validatedDigests=None, _keepServerContents=0): """DOCDOC raises ConfigError. """ if string: contents = string else: try: contents = readPossiblyGzippedFile(fname) except (IOError, zlib.error), e: raise ConfigError("Couldn't decompress %s: %s" % (fname, e))
def __init__(self, string=None, fname=None, validatedDigests=None): """Create a new ServerDirectory object, either from a literal <string> (if specified) or a filename [possibly gzipped]. If validatedDigests is provided, it must be a dict whose keys are the digests of already-validated descriptors. Any descriptor whose (calculated) digest matches doesn't need to be validated again. """ if string: contents = string else: try: contents = readPossiblyGzippedFile(fname) except (IOError, zlib.error), e: raise ConfigError("Couldn't decompress %s: %s" % (fname, e))
def __init__(self, string=None, fname=None, validatedDigests=None): """Create a new ServerDirectory object, either from a literal <string> (if specified) or a filename [possibly gzipped]. If validatedDigests is provided, it must be a dict whose keys are the digests of already-validated descriptors. Any descriptor whose (calculated) digest matches doesn't need to be validated again. """ if string: contents = string else: try: contents = readPossiblyGzippedFile(fname) except (IOError, zlib.error), e: raise ConfigError("Couldn't decompress %s: %s"%(fname,e))
def parseDirectory(fname, validatedDigests=None): """DOCDOC""" try: s = readPossiblyGzippedFile(fname) except (IOError, zlib.error), e: raise ConfigError("Couldn't decompress %s: %s" % (fname, e))
def parseDirectory(fname, validatedDigests=None): """DOCDOC""" try: s = readPossiblyGzippedFile(fname) except (IOError, zlib.error), e: raise ConfigError("Couldn't decompress %s: %s"%(fname,e))