Пример #1
0
        def start(self):
                if not port_available("localhost", self.__port):
                        raise DepotStateException("A depot (or some " +
                                    "other network process) seems to be " +
                                    "running on port %d already!" % self.__port)

                # this uses the repo dir as the static content dir, which means that 
                # static content will not work, but we don't need it anyway for what
                # we are doing.
                scfg = config.SvrConfig(self.__dir, self.__dir, depot.AUTH_DEFAULT,
                    auto_create=True)
                scfg.init_dirs()
                scfg.acquire_in_flight()
                # we rebuild the catalog in a strange way here to avoid rebuilding
                # the index, which doesn't work
                scfg.acquire_catalog(rebuild=False)
                # prevent this depot from indexing
                scfg.catalog.searchdb_update_handle = DummyHandle()

                root = cherrypy.Application(sdepot.DepotHTTP(scfg, None))

                cherrypy.config.update({
                    "environment": "production",
                    "checker.on": True,
                    "log.screen": False,
                    "server.socket_port": self.__port,
                    "server.thread_pool": depot.THREADS_DEFAULT,
                    "server.socket_timeout": depot.SOCKET_TIMEOUT_DEFAULT,
                    "tools.log_headers.on": True
                })

                conf = {
                    "/": {
                        # We have to override cherrypy's default response_class so that
                        # we have access to the write() callable to stream data
                        # directly to the client.
                        "wsgi.response_class": dr.DepotResponse,
                    },
                    "/robots.txt": {
                        "tools.staticfile.on": True,
                        "tools.staticfile.filename": os.path.join(scfg.web_root,
                            "robots.txt")
                    },
                }

                cherrypy.config.update(conf)
                cherrypy.tree.mount(root, "", conf)

                engine = cherrypy.engine
                if hasattr(engine, "signal_handler"):
                    engine.signal_handler.subscribe()
                if hasattr(engine, "console_control_handler"):
                    engine.console_control_handler.subscribe()

                engine.start()
Пример #2
0
                usage("--readonly can only be used with --refresh-index if "
                    "--writable-root is used")

        if (ssl_cert_file and not ssl_key_file) or (ssl_key_file and not
            ssl_cert_file):
                usage("The --ssl-cert-file and --ssl-key-file options must "
                    "must both be provided when using either option.")
        elif ssl_cert_file and ssl_key_file and not port_provided:
                # If they didn't already specify a particular port, use the
                # default SSL port instead.
                port = SSL_PORT_DEFAULT

        # If the program is going to reindex, the port is irrelevant since
        # the program will not bind to a port.
        if not reindex:
                available, msg = port_available(None, port)
                if not available:
                        print "pkg.depotd: unable to bind to the specified " \
                            "port: %d. Reason: %s" % (port, msg)
                        sys.exit(1)
        else:
                # Not applicable for reindexing operations.
                content_root = None

        fork_allowed = not reindex
                
        if nasty:
                scfg = config.NastySvrConfig(repo_path, content_root,
                    AUTH_DEFAULT, auto_create=not readonly,
                    fork_allowed=fork_allowed, writable_root=writable_root)
                scfg.set_nasty(nasty_value)
Пример #3
0
            imagedir = arg
        if (opt == "-a"):
            authority = arg
        if (opt == "-t"):
            title = arg
        if (opt == "-x"):
            desc = arg

    pkg_list = [pat.replace("*", ".*").replace("?", ".") for pat in pargs]
    if len(pkg_list) == 0:
        usage(_("makeimage: must list at least one package to install"))
        return 1

    print "image directory:", imagedir
    if repo != None:
        while not port_available("localhost", port):
            print "Since the port (", port, ") is in use, I am going to try the next port."
            port = port + 1
        dc = depotthread.DepotThread(repo=repo, port=port)
        print "args:", dc.get_args()
        print "starting depot..."
        try:
            dc.start()
            dc.waitforup()
        except depotthread.DepotStateException, e:
            print "unable to start depot."
            sys.exit(1)
        print "depot started."
        depoturl = dc.get_depot_url()

    pt = progress.CommandLineProgressTracker()
Пример #4
0
        if (opt == "-a"):
            authority = arg
        if (opt == "-t"):
            title = arg
        if (opt == "-x"):
            desc = arg

    pkg_list = [ pat.replace("*", ".*").replace("?", ".")
            for pat in pargs ]
    if len(pkg_list) == 0:
        usage(_("makeimage: must list at least one package to install"))
        return 1

    print "image directory:", imagedir
    if repo != None:
        while not port_available("localhost", port):
                print "Since the port (",port,") is in use, I am going to try the next port."
                port = port + 1
        dc = depotthread.DepotThread(repo=repo, port=port)
        print "args:", dc.get_args()
        print "starting depot..."
        try:
            dc.start()
            dc.waitforup()
        except depotthread.DepotStateException, e:
            print "unable to start depot."
            sys.exit(1)
        print "depot started."
        depoturl = dc.get_depot_url()

    pt = progress.CommandLineProgressTracker()
Пример #5
0
        usage("--readonly can only be used with --refresh-index if "
              "--writable-root is used")

    if (ssl_cert_file and not ssl_key_file) or (ssl_key_file
                                                and not ssl_cert_file):
        usage("The --ssl-cert-file and --ssl-key-file options must "
              "must both be provided when using either option.")
    elif ssl_cert_file and ssl_key_file and not port_provided:
        # If they didn't already specify a particular port, use the
        # default SSL port instead.
        port = SSL_PORT_DEFAULT

    # If the program is going to reindex, the port is irrelevant since
    # the program will not bind to a port.
    if not reindex:
        available, msg = port_available(None, port)
        if not available:
            print "pkg.depotd: unable to bind to the specified " \
                "port: %d. Reason: %s" % (port, msg)
            sys.exit(1)
    else:
        # Not applicable for reindexing operations.
        content_root = None

    fork_allowed = not reindex

    if nasty:
        scfg = config.NastySvrConfig(repo_path,
                                     content_root,
                                     AUTH_DEFAULT,
                                     auto_create=not readonly,