コード例 #1
0
ファイル: ServerList.py プロジェクト: rxcomm/mixminion
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)
コード例 #2
0
ファイル: ServerList.py プロジェクト: rxcomm/mixminion
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)
コード例 #3
0
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)
コード例 #4
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)
コード例 #5
0
ファイル: ServerInfo.py プロジェクト: B-Rich/mixminion
 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))
コード例 #6
0
 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))
コード例 #7
0
    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))
コード例 #8
0
ファイル: ServerInfo.py プロジェクト: B-Rich/mixminion
    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))
コード例 #9
0
def parseDirectory(fname, validatedDigests=None):
    """DOCDOC"""
    try:
        s = readPossiblyGzippedFile(fname)
    except (IOError, zlib.error), e:
        raise ConfigError("Couldn't decompress %s: %s" % (fname, e))
コード例 #10
0
ファイル: ServerInfo.py プロジェクト: B-Rich/mixminion
def parseDirectory(fname, validatedDigests=None):
    """DOCDOC"""
    try:
        s = readPossiblyGzippedFile(fname)
    except (IOError, zlib.error), e:
        raise ConfigError("Couldn't decompress %s: %s"%(fname,e))