示例#1
0
def main():
    try:
        conf_filename = None
        api = None
        force = False
        debug = False
        root = "/"
        delete = False
        try:
            opts, arg = getopt.getopt(sys.argv[1:], "hc:vr:df", [
                "help", "config-file=", "verbose", "root=", "delete-endpoint",
                "force"
            ])
        except getopt.GetoptError as e:
            print("Invalid option " + e.opt, file=sys.stderr)
            usage(short=True, outstream=sys.stderr)
            sys.exit(1)

        if len(arg) > 0:
            print("Unexpected argument(s) " + " ".join(arg), file=sys.stderr)
            sys.exit(1)

        for (o, val) in opts:
            if o in ['-h', '--help']:
                usage()
                sys.exit(0)
            elif o in ['-c', '--config-file']:
                conf_filename = val
            elif o in ['-v', '--verbose']:
                debug = True
            elif o in ['-r', '--root']:
                root = val
            elif o in ['-d', '--delete-endpoint']:
                delete = True
            elif o in ['-f', '--force']:
                force = True
            else:
                print("Unknown option %s" % (o), file=sys.stderr)
                sys.exit(1)

        is_latest_version(force)

        os.umask(0o22)
        conf = ConfigFile(config_file=conf_filename, root=root)
        api = get_api(conf)
        ioobj = IO(config_obj=conf, api=api, debug=debug)
        id = ID(config_obj=conf, api=api, debug=debug)
        web = Web(config_obj=conf, api=api, debug=debug)
        web.cleanup()
        ioobj.cleanup(delete=delete)
        id.cleanup()
    except KeyboardInterrupt as e:
        print("Aborting...")
        sys.exit(1)
    except Exception as e:
        if debug:
            traceback.print_exc(file=sys.stderr)
        else:
            print(str(e))
        sys.exit(1)
示例#2
0
def main():
    conf_filename = None
    api = None
    force = False
    debug = False
    reset = False
    root = "/"
    try:
        opts, arg = getopt.getopt(
            sys.argv[1:], "hc:vr:f",
            ["help", "config-file=", "verbose", "root=", "force"])
    except getopt.GetoptError as e:
        print("Invalid option " + e.opt, file=sys.stderr)
        usage(short=True, outstream=sys.stderr)
        sys.exit(1)

    if len(arg) > 0:
        print("Unexpected argument(s) " + " ".join(arg), file=sys.stderr)
        sys.exit(1)

    for (o, val) in opts:
        if o in ['-h', '--help']:
            usage()
            sys.exit(0)
        elif o in ['-c', '--config-file']:
            conf_filename = val
        elif o in ['-v', '--verbose']:
            debug = True
        elif o in ['-r', '--root']:
            root = val
        elif o in ['-f', '--force']:
            force = True
        else:
            print("Unknown option %s" % (o), file=sys.stderr)
            sys.exit(1)

    try:
        is_latest_version(force)

        os.umask(0o22)
        socket.setdefaulttimeout(300)

        conf = ConfigFile(config_file=conf_filename, root=root)
        api = get_api(conf)
        web = Web(config_obj=conf, api=api, password=api.password, debug=debug)
        web.setup()
        sys.exit(web.errorcount)
    except KeyboardInterrupt as e:
        print("Aborting...")
        sys.exit(1)
    except Exception as e:
        if debug:
            traceback.print_exc(file=sys.stderr)
        else:
            print(str(e))
        sys.exit(1)
示例#3
0
            debug = True
        elif o in ['-r', '--root']:
            root = val
        elif o in ['-s', '--reset-endpoint']:
            reset = True
        elif o in ['-f', '--force']:
            force = True
        else:
            print("Unknown option %s" % (o), file=sys.stderr)
            sys.exit(1)

    try:
        is_latest_version(force)

        os.umask(0o22)
        conf = ConfigFile(config_file=conf_filename, root=root)
        api = get_api(conf)
        ioobj = IO(config_obj=conf, api=api, debug=debug)
        ioobj.setup(reset=reset)
        sys.exit(ioobj.errorcount)
    except KeyboardInterrupt as e:
        print("Aborting..")
        sys.exit(1)
    except Exception as e:
        if debug:
            traceback.print_exc(file=sys.stderr)
        else:
            print(str(e))
        sys.exit(1)

# vim: filetype=python: