Esempio n. 1
0
def check_options(opts):
    if not opts.config_path:
        print >>sys.stderr, "-c or --config is required."
        return False

    if not check.type_read_file(opts.config_path):
        print >>sys.stderr, "-c or --config file is specified in the option does not exist."
        return False
    return True
Esempio n. 2
0
    def read(self):
        if not check.type_read_file(self._path):
            return False

        self._read_file = open(self._path, 'r')
        try:
            self.__lock_SH(self._read_file)
            return self._read()
        finally:
            self.__lock_UN(self._read_file)
            self._read_file.close()
        return True
Esempio n. 3
0
def check_config(config):
    normal = True

    if normal and not "log.config" in config:
        print >>sys.stderr, "Configuration information is missing. - log.config"
        normal = False
    if normal and not check.type_file(config["log.config"]):
        print >>sys.stderr, "There is a mistake in the configuration information. - log.config=%s" % config[
            "log.config"
        ]
        normal = False

    if normal and not "bin.dir" in config:
        print >>sys.stderr, "Configuration information is missing. - bin.dir"
        normal = False
    if normal and not check.type_dir(config["bin.dir"]):
        print >>sys.stderr, "There is a mistake in the configuration information. - bin.dir=%s" % config["bin.dir"]
        normal = False
    if normal and not check.type_read_file(config["bin.dir"]):
        print >>sys.stderr, "Not set the appropriate permissions to that directory. - bin.dir=%s" % config["bin.dir"]
        normal = False

    if normal and not "tmp.dir" in config:
        print >>sys.stderr, "Configuration information is missing. - tmp.dir"
        normal = False
    if normal and not check.type_dir(config["tmp.dir"]):
        print >>sys.stderr, "There is a mistake in the configuration information. - tmp.dir=%s" % config["tmp.dir"]
        normal = False
    if normal and not check.type_write_file(config["tmp.dir"]):
        print >>sys.stderr, "Not set the appropriate permissions to that directory. - tmp.dir=%s" % config["tmp.dir"]
        normal = False

    if normal and not "server.interface" in config:
        print >>sys.stderr, "Configuration information is missing. - server.interface"
        normal = False

    if normal and not "server.port" in config:
        print >>sys.stderr, "Configuration information is missing. - server.port"
        normal = False
    if normal and not check.type_int(config["server.port"]):
        print >>sys.stderr, "Please set it by the numerical value. - server.port=%s" % config["server.port"]
        normal = False

    if normal and not "uniqkey" in config:
        print >>sys.stderr, "Configuration information is missing. - uniqkey"
        normal = False
    if normal and not check.type_uuid(config["uniqkey"]):
        print >>sys.stderr, "UUID format is not set. - uniqkey"
        normal = False

    return normal