From c646dd47d0f75eb568ebadea4e9f64a8f9a14db3 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Thu, 13 Jul 2017 20:09:10 +0800 Subject: decouple the mutual-dependence of config.py and server.py Currently server.py relies on CONF while starting the service, and config.py's config_fie is set in server.py, which is wrongly bi-depended this patch aims to let Config parse the sys.argv personally, just as oslo.config do, so that decouple the mutual-dependency Change-Id: I46887d122a98d478caebe9eeb7ab038941ce1f6b Signed-off-by: SerenaFeng --- utils/test/testapi/opnfv_testapi/cmd/server.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'utils/test/testapi/opnfv_testapi/cmd') diff --git a/utils/test/testapi/opnfv_testapi/cmd/server.py b/utils/test/testapi/opnfv_testapi/cmd/server.py index 545d5e367..e640d5f8c 100644 --- a/utils/test/testapi/opnfv_testapi/cmd/server.py +++ b/utils/test/testapi/opnfv_testapi/cmd/server.py @@ -29,29 +29,13 @@ TODOs : """ -import argparse -import sys - import motor import tornado.ioloop -from opnfv_testapi.common import config +from opnfv_testapi.common.config import CONF from opnfv_testapi.router import url_mappings from opnfv_testapi.tornado_swagger import swagger -CONF = None - - -def parse_config(argv=[]): - global CONF - parser = argparse.ArgumentParser() - parser.add_argument("-c", "--config-file", dest='config_file', - help="Config file location") - args = parser.parse_args(argv) - if args.config_file: - config.Config.CONFIG = args.config_file - CONF = config.Config() - def get_db(): return motor.MotorClient(CONF.mongo_url)[CONF.mongo_dbname] @@ -70,7 +54,6 @@ def make_app(): def main(): - parse_config(sys.argv[1:]) application = make_app() application.listen(CONF.api_port) tornado.ioloop.IOLoop.current().start() -- cgit 1.2.3-korg