diff --git a/bin/swh-web-ui b/bin/swh-web-ui index 6d3621ff..e1d84b67 100755 --- a/bin/swh-web-ui +++ b/bin/swh-web-ui @@ -1,61 +1,60 @@ #!/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 controller -from swh.storage import Storage # Default configuration file DEFAULT_CONF_FILE = '~/.config/swh/web-ui.ini' # default configuration DEFAULT_CONF = { 'storage_args': ('list[str]', ['http://localhost:5000/']), 'storage_class': ('str', 'remote_storage'), 'log_dir': ('string', '/tmp/swh/loader-git/log'), - 'debug': ('bool' , None), + 'debug': ('bool', None), 'host': ('string', '127.0.0.1'), - 'port': ('int' , 6543), + 'port': ('int', 6543), } 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') if conf['storage_class'] == 'remote_storage': from swh.storage.api.client import RemoteStorage as Storage else: from swh.storage import Storage conf.update({ 'storage': Storage(*conf['storage_args']) }) logging.basicConfig(filename=os.path.join(conf['log_dir'], 'web-ui.log'), level=logging.DEBUG if args.verbose else logging.INFO) controller.run(conf) diff --git a/swh/web/ui/tests/test_query.py b/swh/web/ui/tests/test_query.py index 6a2010cb..d579144d 100644 --- a/swh/web/ui/tests/test_query.py +++ b/swh/web/ui/tests/test_query.py @@ -1,35 +1,36 @@ # 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 unittest from nose.tools import istest from swh.web.ui import query from swh.core import hashutil + class QueryTestCase(unittest.TestCase): @istest def categorize_hash(self): input_sha1 = 'f1d2d2f924e986ac86fdf7b36c94bcdf32beec15' res = query.categorize_hash(input_sha1) self.assertEquals(res, {'sha1': hashutil.hex_to_hash(input_sha1)}) def categorize_hash_2(self): input_sha256 = \ '084c799cd551dd1d8d5c5f9a5d593b2e931f5e36122ee5c793c1d08a19839cc0' res = query.categorize_hash(input_sha256) self.assertEquals(res, {'sha256': hashutil.hex_to_hash(input_sha256)}) def categorize_hash_3(self): input_bad_length = '1234567890987654' res = query.categorize_hash(input_bad_length) self.assertEquals(res, {})