diff --git a/bin/swh-backend b/bin/swh-backend index 023e5ed..61d7f51 100755 --- a/bin/swh-backend +++ b/bin/swh-backend @@ -1,58 +1,57 @@ #!/usr/bin/env python3 -# Copyright (C) 2015 Stefano Zacchiroli , -# Antoine R. Dumont +# Copyright (C) 2015 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import argparse import logging import os from swh.core import config from swh.loader.git.backend import api from swh.storage.objstorage import ObjStorage # Default configuration file DEFAULT_CONF_FILE = '~/.config/swh/back.ini' # default configuration DEFAULT_CONF = { 'content_storage_dir' : ('string', '/tmp/swh-loader-git/content-storage'), 'log_dir' : ('string', '/tmp/swh-loader-git/log'), 'db_url' : ('string', 'dbname=softwareheritage-dev'), 'folder_depth' : ('int' , 4), 'debug' : ('bool' , None), 'host' : ('string', '127.0.0.1'), 'port' : ('int' , 5000) } def parse_args(): """Parse the configuration for the cli. """ cli = argparse.ArgumentParser( description='Parse git repository objects to load them into DB.') cli.add_argument('--verbose', '-v', action='store_true', help='Verbosity level in log file.') cli.add_argument('--config', '-c', help='configuration file path') args = cli.parse_args() return args if __name__ == '__main__': args = parse_args() conf = config.read(args.config or DEFAULT_CONF_FILE, DEFAULT_CONF) config.prepare_folders(conf, 'log_dir', 'content_storage_dir') conf.update({ 'objstorage': ObjStorage(conf['content_storage_dir'], conf['folder_depth']) }) logging.basicConfig(filename=os.path.join(conf['log_dir'], 'back.log'), level=logging.DEBUG if args.verbose else logging.INFO) api.run(conf) diff --git a/bin/swh-db-manager b/bin/swh-db-manager index 05caae9..190455a 100755 --- a/bin/swh-db-manager +++ b/bin/swh-db-manager @@ -1,57 +1,56 @@ #!/usr/bin/env python3 -# Copyright (C) 2015 Stefano Zacchiroli , -# Antoine R. Dumont +# Copyright (C) 2015 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import argparse import logging import os from swh.core import config from swh.loader.git import manager # Default configuration file DEFAULT_CONF_FILE = '~/.config/swh/db-manager.ini' # default configuration (can be overriden by the DEFAULT_CONF_FILE) DEFAULT_CONF = { 'log_dir': ('string', '/tmp/swh-loader-git/log'), 'db_url' : ('string', 'dbname=softwareheritage-dev') } def parse_args(): """Parse the configuration for the cli. """ cli = argparse.ArgumentParser( description='Parse git repository objects to load them into DB.') cli.add_argument('--verbose', '-v', action='store_true', help='Verbosity level in log file.') cli.add_argument('--config', '-c', help='configuration file path') subcli = cli.add_subparsers(dest='action') subcli.add_parser('initdb', help='initialize DB') subcli.add_parser('cleandb', help='clean DB') args = cli.parse_args() if not args.action: cli.error('no action given') return args if __name__ == '__main__': args = parse_args() conf = config.read(args.config or DEFAULT_CONF_FILE, DEFAULT_CONF) config.prepare_folders(conf, 'log_dir') logging.basicConfig(filename=os.path.join(conf['log_dir'], 'db-manager.log'), level=logging.DEBUG if args.verbose else logging.INFO) manager.manage(args.action, conf['db_url']) diff --git a/bin/swh-loader-git b/bin/swh-loader-git index d35920a..5da33ce 100755 --- a/bin/swh-loader-git +++ b/bin/swh-loader-git @@ -1,69 +1,68 @@ #!/usr/bin/env python3 -# Copyright (C) 2015 Stefano Zacchiroli , -# Antoine R. Dumont +# Copyright (C) 2015 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import argparse import logging import os from swh.core import config from swh.loader.git import loader # Default configuration file DEFAULT_CONF_FILE = '~/.config/swh/loader-git.ini' # default configuration (can be overriden by the DEFAULT_CONF_FILE) DEFAULT_CONF = { 'log_dir': ('string', '/tmp/swh-loader-git/log'), 'backend-type': ('string', 'remote'), 'backend': ('string', 'http://localhost:5000'), } # Another example of configuration: # DEFAULT_CONF = { # 'log_dir': ('string', '/tmp/swh-loader-git/log'), # 'backend-type': ('string', 'local'), # 'backend': ('string', '~/.config/swh/back.ini'), # } def parse_args(): """Parse the CLI arguments. """ cli = argparse.ArgumentParser( description='Parse git repository objects to load them into DB.') cli.add_argument('--verbose', '-v', action='store_true', help='Verbosity level in log file.') cli.add_argument('--config', '-c', help='configuration file path') subcli = cli.add_subparsers(dest='action') load_cli = subcli.add_parser('load', help='load Git repo into DB') load_cli.add_argument('repository', help='Git repository path') args = cli.parse_args() if not args.action: cli.error('no action given') return args if __name__ == '__main__': args = parse_args() conf = config.read(args.config or DEFAULT_CONF_FILE, DEFAULT_CONF) config.prepare_folders(conf, 'log_dir') conf['action'] = args.action conf['repo_path'] = args.repository logging.basicConfig(filename=os.path.join(conf['log_dir'], 'sgloader.log'), level=logging.DEBUG if args.verbose else logging.INFO) loader.load(conf)