def read_server_config(filename): """ Read a server's configuration information. filename: string Path to file to be read. Returns a dictionary containing 'address', 'port', 'tunnel', 'key', and 'logfile' information """ if not os.path.exists(filename): raise IOError('No such file %r' % filename) parser = ConfigParser.ConfigParser() parser.read(filename) section = 'ServerInfo' cfg = {} cfg['address'] = parser.get(section, 'address') cfg['port'] = parser.getint(section, 'port') cfg['tunnel'] = parser.getboolean(section, 'tunnel') key = parser.get(section, 'key') if key: key = decode_public_key(key) cfg['key'] = key cfg['logfile'] = parser.get(section, 'logfile') cfg['version'] = parser.get(section, 'version') return cfg
def read_server_config(filename): """ Read a server's configuration information. filename: string Path to file to be read. Returns a dictionary containing 'address', 'port', 'tunnel', 'key', and 'logfile' information. """ if not os.path.exists(filename): raise IOError("No such file %r" % filename) parser = ConfigParser.ConfigParser() parser.read(filename) section = "ServerInfo" cfg = {} cfg["address"] = parser.get(section, "address") cfg["port"] = parser.getint(section, "port") cfg["tunnel"] = parser.getboolean(section, "tunnel") key = parser.get(section, "key") if key: key = decode_public_key(key) cfg["key"] = key cfg["logfile"] = parser.get(section, "logfile") cfg["version"] = parser.get(section, "version") return cfg
def read_server_config(filename): """ Read a server's configuration information. filename: string Path to file to be read. Returns a dictionary containing 'address', 'port', 'tunnel', 'key', and 'logfile' information. """ if not os.path.exists(filename): raise IOError('No such file %r' % filename) parser = ConfigParser.ConfigParser() parser.read(filename) section = 'ServerInfo' cfg = {} cfg['address'] = parser.get(section, 'address') cfg['port'] = parser.getint(section, 'port') cfg['tunnel'] = parser.getboolean(section, 'tunnel') key = parser.get(section, 'key') if key: key = decode_public_key(key) cfg['key'] = key cfg['logfile'] = parser.get(section, 'logfile') cfg['version'] = parser.get(section, 'version') return cfg
def read_server_config(filename): """ Read a server's connection information. filename: string Path to file to be read. Returns ``(address, port, key)``. """ if not os.path.exists(filename): raise IOError("No such file %r" % filename) parser = ConfigParser.ConfigParser() parser.read(filename) section = "ServerInfo" address = parser.get(section, "address") port = parser.getint(section, "port") key = parser.get(section, "key") if key: key = decode_public_key(key) return (address, port, key)