Page MenuHomeSoftware Heritage

swh-web-ui
No OneTemporary

swh-web-ui

#!/usr/bin/env python3
# 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.web.ui import api
from swh.storage import Storage
# Default configuration file
DEFAULT_CONF_FILE = '~/.config/swh/web-ui.ini'
# default configuration
DEFAULT_CONF = {
'log_dir': ('string', '/tmp/swh-loader-git/log'),
'db_url': ('string', 'dbname=softwareheritage-dev'),
'debug': ('bool' , None),
'host': ('string', '127.0.0.1'),
'port': ('int' , 6543),
# 'api': ('string', 'http://127.0.0.1:5000') # FIXME: use storage directly
}
def parse_args():
"""Parse the configuration for the cli.
"""
cli = argparse.ArgumentParser(description="SWH's web ui.")
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')
conf.update({
'storage': Storage(conf['db_url'],
"/tmp/swh-loader-git/content-storage/") # hard-coded right now
})
logging.basicConfig(filename=os.path.join(conf['log_dir'], 'web-ui.log'),
level=logging.DEBUG if args.verbose else logging.INFO)
api.run(conf)

File Metadata

Mime Type
text/x-python
Expires
Fri, Jul 4, 4:17 PM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3451553

Event Timeline