Exemplo n.º 1
0
def _main(pluginmanager, argv=None):
    # During parsing of options logging should not be used

    if argv is None:
        argv = sys.argv

    argv = [str(x) for x in argv]
    config = parseoptions(pluginmanager, argv)
    args = config.args

    # meta commmands
    if args.version:
        print(server_version)
        return

    if args.genconfig:
        from devpi_server.genconfig import genconfig
        return genconfig(config)

    configure_logging(config.args)

    # read/create node UUID and role of this server
    config.init_nodeinfo()

    xom = XOM(config)
    if not xom.is_replica():
        with xom.keyfs.transaction(write=True):
            set_default_indexes(xom.model)
    check_compatible_version(xom)

    if args.start or args.stop or args.log or args.status:
        xprocdir = config.serverdir.join(".xproc")
        from devpi_server.bgserver import BackgroundServer
        tw = py.io.TerminalWriter()
        bgserver = BackgroundServer(tw, xprocdir)
        if args.start:
            return bgserver.start(args)
        elif args.stop:
            return bgserver.stop()
        elif args.log:
            return bgserver.log()
        elif args.status:
            if bgserver.info.isrunning():
                bgserver.line("server is running with pid %s" %
                              bgserver.info.pid)
            else:
                bgserver.line("no server is running")
            return

    if args.passwd:
        from devpi_server.model import run_passwd
        with xom.keyfs.transaction(write=True):
            return run_passwd(xom.model, config.args.passwd)

    return xom.main()
Exemplo n.º 2
0
def _main(argv=None, hook=None):
    if argv is None:
        argv = sys.argv

    argv = [str(x) for x in argv]
    config = parseoptions(argv, hook=hook)
    args = config.args

    # meta commmands
    if args.version:
        print(server_version)
        return

    if args.genconfig:
        from devpi_server.genconfig import genconfig
        return genconfig(config)

    configure_logging(config)
    xom = XOM(config)
    if not xom.is_replica():
        with xom.keyfs.transaction(write=True):
            set_default_indexes(xom.model)
    check_compatible_version(xom)

    if args.start or args.stop or args.log or args.status:
        xprocdir = config.serverdir.join(".xproc")
        from devpi_server.bgserver import BackgroundServer
        tw = py.io.TerminalWriter()
        bgserver = BackgroundServer(tw, xprocdir)
        if args.start:
            return bgserver.start(args)
        elif args.stop:
            return bgserver.stop()
        elif args.log:
            return bgserver.log()
        elif args.status:
            if bgserver.info.isrunning():
                bgserver.line("server is running with pid %s" %
                              bgserver.info.pid)
            else:
                bgserver.line("no server is running")
            return

    if args.passwd:
        from devpi_server.model import run_passwd
        return run_passwd(xom.db, config.args.passwd)

    return xom.main()
Exemplo n.º 3
0
def _main(pluginmanager, argv=None):
    # During parsing of options logging should not be used

    if argv is None:
        argv = sys.argv

    argv = [str(x) for x in argv]
    config = parseoptions(pluginmanager, argv)
    args = config.args

    # meta commmands
    if args.version:
        print(server_version)
        return 0

    if args.genconfig:
        from devpi_server.genconfig import genconfig
        return genconfig(config, argv[1:])

    configure_logging(config.args)

    if args.init:
        if config.path_nodeinfo.exists():
            fatal("The path '%s' already contains devpi-server data." %
                  config.serverdir)
    elif not args.import_:
        if not config.path_nodeinfo.exists():
            fatal(
                "The path '%s' contains no devpi-server data, use --init to initialize."
                % config.serverdir)

    if args.init or args.import_:
        sdir = config.serverdir
        if not (sdir.exists() and len(sdir.listdir()) >= 2):
            set_state_version(config, DATABASE_VERSION)
    else:
        check_compatible_version(config)

    # read/create node UUID and role of this server
    config.init_nodeinfo()

    if config.sqlite_file_needed_but_missing():
        fatal("No sqlite storage found in serverdir."
              " Or you need to run with --storage to specify the storage type,"
              " or you first need to run with --init or --import"
              " in order to create the sqlite database.")

    xom = XOM(config)
    # we deliberately call get_current_serial first to establish a connection
    # to the backend and in case of sqlite create the database
    if xom.keyfs.get_current_serial() == -1 and not xom.is_replica():
        with xom.keyfs.transaction(write=True):
            set_default_indexes(xom.model)

    if args.start or args.stop or args.log or args.status:
        xprocdir = config.serverdir.join(".xproc")
        from devpi_server.bgserver import BackgroundServer
        tw = py.io.TerminalWriter()
        bgserver = BackgroundServer(tw, xprocdir)
        if args.start:
            return bgserver.start(args, argv[1:])
        elif args.stop:
            return bgserver.stop()
        elif args.log:
            return bgserver.log()
        elif args.status:
            if bgserver.info.isrunning():
                bgserver.line("server is running with pid %s" %
                              bgserver.info.pid)
            else:
                bgserver.line("no server is running")
            return

    if args.passwd:
        from devpi_server.model import run_passwd
        with xom.keyfs.transaction(write=True):
            return run_passwd(xom.model, config.args.passwd)

    if args.init:
        return 0

    return xom.main()
Exemplo n.º 4
0
def _main(pluginmanager, argv=None):
    # During parsing of options logging should not be used

    if argv is None:
        argv = sys.argv

    argv = [str(x) for x in argv]
    config = parseoptions(pluginmanager, argv)
    args = config.args

    # meta commmands
    if args.version:
        print(server_version)
        return 0

    if args.genconfig:
        from devpi_server.genconfig import genconfig
        return genconfig(config, argv[1:])

    configure_logging(config.args)

    if args.init:
        if config.path_nodeinfo.exists():
            fatal("The path '%s' already contains devpi-server data." %
                  config.serverdir)
    elif not args.import_:
        if not config.path_nodeinfo.exists():
            fatal(
                "The path '%s' contains no devpi-server data, use --init to initialize."
                % config.serverdir)

    # read/create node UUID and role of this server
    config.init_nodeinfo()

    xom = XOM(config)
    if not xom.is_replica() and xom.keyfs.get_current_serial() == -1:
        with xom.keyfs.transaction(write=True):
            set_default_indexes(xom.model)
    check_compatible_version(xom)

    if args.start or args.stop or args.log or args.status:
        xprocdir = config.serverdir.join(".xproc")
        from devpi_server.bgserver import BackgroundServer
        tw = py.io.TerminalWriter()
        bgserver = BackgroundServer(tw, xprocdir)
        if args.start:
            return bgserver.start(args, argv[1:])
        elif args.stop:
            return bgserver.stop()
        elif args.log:
            return bgserver.log()
        elif args.status:
            if bgserver.info.isrunning():
                bgserver.line("server is running with pid %s" %
                              bgserver.info.pid)
            else:
                bgserver.line("no server is running")
            return

    if args.passwd:
        from devpi_server.model import run_passwd
        with xom.keyfs.transaction(write=True):
            return run_passwd(xom.model, config.args.passwd)

    if args.init:
        return 0

    return xom.main()
Exemplo n.º 5
0
def _main(pluginmanager, argv=None):
    # During parsing of options logging should not be used

    if argv is None:
        argv = sys.argv

    argv = [str(x) for x in argv]
    config = parseoptions(pluginmanager, argv)
    args = config.args

    # meta commmands
    if args.version:
        print(server_version)
        return 0

    if args.genconfig:
        from devpi_server.genconfig import genconfig
        import warnings
        warnings.warn(
            "DEPRECATION: the --gen-config option is deprecated, use the "
            "devpi-gen-config command instead")
        return genconfig(config, argv)

    # now we can configure logging
    configure_logging(config.args)

    if args.init:
        import warnings
        warnings.warn("DEPRECATION: the --init option is deprecated, use the "
                      "devpi-init command instead")
        if config.path_nodeinfo.exists():
            fatal("The path '%s' already contains devpi-server data." %
                  config.serverdir)
    elif not args.import_:
        if not config.path_nodeinfo.exists():
            fatal(
                "The path '%s' contains no devpi-server data, use devpi-init to initialize."
                % config.serverdir)

    if args.init or args.import_:
        sdir = config.serverdir
        if not (sdir.exists() and len(sdir.listdir()) >= 2):
            set_state_version(config, DATABASE_VERSION)

    xom = xom_from_config(config)

    init_default_indexes(xom)

    if args.start or args.stop or args.log or args.status:
        xprocdir = config.serverdir.join(".xproc")
        from devpi_server.bgserver import BackgroundServer
        tw = py.io.TerminalWriter()
        bgserver = BackgroundServer(tw, xprocdir)
        if args.start:
            return bgserver.start(args, argv[1:])
        elif args.stop:
            return bgserver.stop()
        elif args.log:
            return bgserver.log()
        elif args.status:
            if bgserver.info.isrunning():
                bgserver.line("server is running with pid %s" %
                              bgserver.info.pid)
            else:
                bgserver.line("no server is running")
            return

    if args.passwd:
        from devpi_server.model import run_passwd
        import warnings
        warnings.warn(
            "DEPRECATION: the --passwd option is deprecated, use the "
            "devpi-passwd command instead")
        with xom.keyfs.transaction(write=True):
            return run_passwd(xom.model, config.args.passwd)

    if args.init:
        return 0

    return xom.main()