def marvcli_pip_uninstall(pipargs): """Uninstall python package (EE).""" assert within_pyinstaller_bundle() siteconf = get_site_config() sitepackages = make_config(siteconf).marv.sitepackages load_sitepackages(sitepackages) ensure_python(siteconf, sitepackages) from pip._internal.main import main as pip_main # pylint: disable=import-outside-toplevel sys.argv = [sys.executable, 'uninstall', *pipargs] sys.exit(pip_main())
def marvcli_python(unbuffered, ignore, command, args): # pylint: disable=unused-argument """Drop into interactive python (EE).""" assert within_pyinstaller_bundle() siteconf = get_site_config() sitepackages = make_config(siteconf).marv.sitepackages load_sitepackages(sitepackages) ensure_python(siteconf, sitepackages) if command: sys.argv = ['-c', *args] sys.path.append('.') exec(compile(command, 'python_wrapper', 'exec')) # pylint: disable=exec-used else: code.interact(local=locals())
def marvcli_dump(dump_file): """Dump database to json file. Use '-' for stdout. """ ctx = click.get_current_context() if ctx.obj is None: ctx.fail('Could not find config file: ./marv.conf or /etc/marv/marv.conf.\n' 'Change working directory or specify explicitly:\n\n' ' marv --config /path/to/marv.conf\n') siteconf = make_config(ctx.obj) dump = dump_database(siteconf.marv.dburi) json.dump(dump, dump_file, sort_keys=True, indent=2)
def marvcli_pip_install(pipargs): """Install python package (EE). Use -e like with plain pip to install in editable mode. """ assert within_pyinstaller_bundle() siteconf = get_site_config() config = make_config(siteconf) sitepackages = config.marv.sitepackages load_sitepackages(sitepackages) ensure_python(siteconf, sitepackages) from pip._internal.main import main as pip_main # pylint: disable=import-outside-toplevel sys.argv = [ sys.executable, 'install', '--prefix', str(config.marv.venv), *pipargs ] sys.exit(pip_main())
async def marvcli_dump(dump_file): """Dump database to json file. Use '-' for stdout. """ if str(dump_file) != '-' and dump_file.exists(): err('ERROR: Dump file must not exist already!', exit=1) siteconf = make_config(get_site_config()) try: dump = await Site.Database.dump_database(siteconf.marv.dburi) except (DBNotInitialized, DBVersionError) as exc: err(f'ERROR: {exc}', exit=1) if str(dump_file) == '-': json.dump(dump, sys.stdout, sort_keys=True, indent=2) else: with dump_file.open('w') as f: json.dump(dump, f, sort_keys=True, indent=2)