def main(self): xom = self args = xom.config.args if args.export: from devpi_server.importexport import do_export #xom.thread_pool.start_one(xom.keyfs.notifier) return do_export(args.export, xom) if args.import_: from devpi_server.importexport import do_import # we need to start the keyfs notifier so that import # can wait on completion of events if args.wait_for_events: xom.thread_pool.start_one(xom.keyfs.notifier) return do_import(args.import_, xom) # creation of app will register handlers of key change events # which cannot happen anymore after the tx notifier has started with xom.keyfs.transaction(): res = xom.config.hook.devpiserver_cmdline_run(xom=xom) if res is not None: return res app = xom.create_app() with xom.thread_pool.live(): if xom.is_replica(): # XXX ground restart_as_write_transaction better xom.keyfs.restart_as_write_transaction = None return wsgi_run(xom, app)
def main(self): xom = self args = xom.config.args if args.upgrade_state: from devpi_server.importexport import do_upgrade return do_upgrade(xom) if args.export: from devpi_server.importexport import do_export return do_export(args.export, xom) configure_logging(xom.config) # access extdb to make sure invalidation happens xom.extdb if args.import_: from devpi_server.importexport import do_import return do_import(args.import_, xom) return bottle_run(xom)
def main(self): xom = self args = xom.config.args if args.upgrade_state: from devpi_server.importexport import do_upgrade return do_upgrade(xom) # need to initialize the pypi mirror state before importing # because importing may need pypi mirroring state if xom.is_replica(): proxy = replica.PyPIProxy(xom._httpsession, xom.config.master_url) else: proxy = self.proxy xom.pypimirror.init_pypi_mirror(proxy) if args.export: from devpi_server.importexport import do_export #xom.thread_pool.start_one(xom.keyfs.notifier) return do_export(args.export, xom) if args.import_: from devpi_server.importexport import do_import # we need to start the keyfs notifier so that import # can wait on completion of events xom.thread_pool.start_one(xom.keyfs.notifier) return do_import(args.import_, xom) # creation of app will register handlers of key change events # which cannot happen anymore after the tx notifier has started with xom.keyfs.transaction(): results = xom.config.hook.devpiserver_run_commands(xom) if [x for x in results if x is not None]: errors = list(filter(None, results)) if errors: return errors[0] return 0 app = xom.create_app() with xom.thread_pool.live(): if xom.is_replica(): # XXX ground restart_as_write_transaction better xom.keyfs.restart_as_write_transaction = None return wsgi_run(xom, app)
def test_import_wrong_dumpversion(tmpdir, xom): tmpdir.join("dataindex.json").write('{"dumpversion": "0"}') with pytest.raises(Fatal): do_import(tmpdir, xom)
def test_not_exists(tmpdir, xom): p = tmpdir.join("hello") with pytest.raises(Fatal): do_import(p, xom)
def test_import_on_existing_server_data(tmpdir, xom): with xom.keyfs.transaction(write=True): xom.model.create_user("someuser", password="******") assert not make_export(tmpdir, xom) with pytest.raises(Fatal): do_import(tmpdir, xom)