From f0b58f8c2717339901683e79c439e8423ae4bab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Antal?= Date: Tue, 15 Dec 2015 17:48:40 +0100 Subject: [PATCH] Removed duplicated function prepare_service() The prepare_service() function is defined both in watcher/service.py and in watcher/common/service.py. These 2 needed to be merged into a single one to avoid code duplication. At the same time, the watcher/service.py only contains this function, so I removed that file. Change-Id: I0c935dfcd011bee9597315752dae8668221c53f9 Closes-Bug: #1525842 --- watcher/cmd/api.py | 2 +- watcher/common/service.py | 8 +++++--- watcher/service.py | 29 ----------------------------- 3 files changed, 6 insertions(+), 33 deletions(-) delete mode 100644 watcher/service.py diff --git a/watcher/cmd/api.py b/watcher/cmd/api.py index 71c4a7c72..74fed0368 100644 --- a/watcher/cmd/api.py +++ b/watcher/cmd/api.py @@ -26,7 +26,7 @@ from oslo_log import log as logging from watcher._i18n import _ from watcher.api import app as api_app -from watcher import service +from watcher.common import service LOG = logging.getLogger(__name__) diff --git a/watcher/common/service.py b/watcher/common/service.py index dfbdea4e3..0f6055cfe 100644 --- a/watcher/common/service.py +++ b/watcher/common/service.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. +import logging import signal import socket @@ -124,9 +125,10 @@ _DEFAULT_LOG_LEVELS = ['amqp=WARN', 'amqplib=WARN', 'qpid.messaging=INFO', 'glanceclient=WARN', 'watcher.openstack.common=WARN'] -def prepare_service(argv=[]): - log.register_options(cfg.CONF) +def prepare_service(argv=[], conf=cfg.CONF): + log.register_options(conf) config.parse_args(argv) cfg.set_defaults(_options.log_opts, default_log_levels=_DEFAULT_LOG_LEVELS) - log.setup(cfg.CONF, 'python-watcher') + log.setup(conf, 'python-watcher') + conf.log_opt_values(LOG, logging.DEBUG) diff --git a/watcher/service.py b/watcher/service.py deleted file mode 100644 index a4f3302eb..000000000 --- a/watcher/service.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- encoding: utf-8 -*- -# Copyright (c) 2015 b<>com -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import logging - -from oslo_config import cfg -from oslo_log import log - -LOG = log.getLogger(__name__) - - -def prepare_service(args=None, conf=cfg.CONF): - log.register_options(conf) - log.setup(conf, 'watcher') - conf(args, project='python-watcher') - conf.log_opt_values(LOG, logging.DEBUG)