From fdd68c03b90d2ebdb1131c0588caeb52eaa116ae Mon Sep 17 00:00:00 2001 From: yujunglo Date: Thu, 21 Jan 2016 15:39:43 -0800 Subject: [PATCH] Fixed agent config and logging --- deploy-agent/.bumpversion.cfg | 2 +- deploy-agent/deployd/agent.py | 14 ++++++++++---- deploy-agent/deployd/common/config.py | 1 + deploy-agent/deployd/download/downloader.py | 8 +++++--- deploy-agent/deployd/staging/stager.py | 3 ++- deploy-agent/setup.py | 2 +- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/deploy-agent/.bumpversion.cfg b/deploy-agent/.bumpversion.cfg index d281f4087e..893c1fa009 100644 --- a/deploy-agent/.bumpversion.cfg +++ b/deploy-agent/.bumpversion.cfg @@ -2,5 +2,5 @@ files = setup.py commit = True tag = True -current_version = 1.2.1 +current_version = 1.2.2 diff --git a/deploy-agent/deployd/agent.py b/deploy-agent/deployd/agent.py index 0789dd73a0..afe51edea3 100644 --- a/deploy-agent/deployd/agent.py +++ b/deploy-agent/deployd/agent.py @@ -192,14 +192,20 @@ def get_download_script(self, deploy_goal): url = deploy_goal.build.artifactUrl build = deploy_goal.build.buildId env_name = self._curr_report.report.envName - return ['deploy-downloader', '-f', self._config.get_config_filename(), - '-v', build, '-u', url, "-e", env_name] + if not self._config.get_config_filename(): + return ['deploy-downloader', '-v', build, '-u', url, "-e", env_name] + else: + return ['deploy-downloader', '-f', self._config.get_config_filename(), + '-v', build, '-u', url, "-e", env_name] def get_staging_script(self): build = self._curr_report.build_info.build_id env_name = self._curr_report.report.envName - return ['deploy-stager', '-f', self._config.get_config_filename(), - '-v', build, '-t', self._config.get_target(), "-e", env_name] + if not self._config.get_config_filename(): + return ['deploy-stager', '-v', build, '-t', self._config.get_target(), "-e", env_name] + else: + return ['deploy-stager', '-f', self._config.get_config_filename(), + '-v', build, '-t', self._config.get_target(), "-e", env_name] def _update_ping_reports(self, deploy_report): if self._curr_report: diff --git a/deploy-agent/deployd/common/config.py b/deploy-agent/deployd/common/config.py index 09a800b8d9..debc7f386c 100644 --- a/deploy-agent/deployd/common/config.py +++ b/deploy-agent/deployd/common/config.py @@ -31,6 +31,7 @@ class Config(object): def __init__(self, filenames=None, config_reader=None): self._configs = {} + self._filenames = None if config_reader: self._config_reader = config_reader return diff --git a/deploy-agent/deployd/download/downloader.py b/deploy-agent/deployd/download/downloader.py index a5bb7bb868..ac090f3083 100644 --- a/deploy-agent/deployd/download/downloader.py +++ b/deploy-agent/deployd/download/downloader.py @@ -29,8 +29,7 @@ class Downloader(object): - def __init__(self, config_fn, build, url, env_name): - config = Config(config_fn) + def __init__(self, config, build, url, env_name): self._matcher = re.compile(r'^.*?[.](?Ptar\.gz|tar\.bz2|\w+)$') self._base_dir = config.get_builds_directory() self._build_name = env_name @@ -107,8 +106,11 @@ def main(): parser.add_argument('-e', '--env-name', dest='env_name', required=True, help="the environment name currently in deploy.") args = parser.parse_args() + config = Config(args.config_file) + logging.basicConfig(level=config.get_log_level()) - status = Downloader(args.config_file, args.build, args.url, args.env_name).download() + log.info("Start to download the package.") + status = Downloader(config, args.build, args.url, args.env_name).download() if status != Status.SUCCEEDED: log.error("Download failed.") sys.exit(1) diff --git a/deploy-agent/deployd/staging/stager.py b/deploy-agent/deployd/staging/stager.py index ea9218bf7f..ba692fe644 100644 --- a/deploy-agent/deployd/staging/stager.py +++ b/deploy-agent/deployd/staging/stager.py @@ -135,9 +135,10 @@ def main(): parser.add_argument('-e', '--env-name', dest='env_name', required=True, help="the environment name currently in deploy.") args = parser.parse_args() + config = Config(args.config_file) + logging.basicConfig(level=config.get_log_level()) log.info("Start to stage the package.") - config = Config(args.config_file) result = Stager(config=config, build=args.build, target=args.target, env_name=args.env_name).enable_package() if result == Status.SUCCEEDED: diff --git a/deploy-agent/setup.py b/deploy-agent/setup.py index 77f7baef78..6f997e7204 100644 --- a/deploy-agent/setup.py +++ b/deploy-agent/setup.py @@ -15,7 +15,7 @@ from setuptools import setup import os -__version__ = '1.2.1' +__version__ = '1.2.2' markdown_contents = open(os.path.join(os.path.dirname(__file__), 'README.md')).read()