Skip to content

Commit

Permalink
Fixed agent config and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
yujunglo committed Jan 22, 2016
1 parent fb0075e commit fdd68c0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion deploy-agent/.bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
files = setup.py
commit = True
tag = True
current_version = 1.2.1
current_version = 1.2.2

14 changes: 10 additions & 4 deletions deploy-agent/deployd/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions deploy-agent/deployd/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions deploy-agent/deployd/download/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'^.*?[.](?P<ext>tar\.gz|tar\.bz2|\w+)$')
self._base_dir = config.get_builds_directory()
self._build_name = env_name
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion deploy-agent/deployd/staging/stager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion deploy-agent/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit fdd68c0

Please sign in to comment.