diff --git a/fuel_upgrade_system/fuel_update_downloader/bin/fuel-update-downloader b/fuel_upgrade_system/fuel_update_downloader/bin/fuel-update-downloader deleted file mode 100755 index 0c1afd9d13..0000000000 --- a/fuel_upgrade_system/fuel_update_downloader/bin/fuel-update-downloader +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2014 Mirantis, Inc. -# -# 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 os -import sys - - -sys.path[:0] = [os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))] - - -from fuel_update_downloader.cli import main - - -if __name__ == '__main__': - main() diff --git a/fuel_upgrade_system/fuel_update_downloader/fuel_update_downloader/cli.py b/fuel_upgrade_system/fuel_update_downloader/fuel_update_downloader/cli.py index 190087095b..d80b41af5c 100644 --- a/fuel_upgrade_system/fuel_update_downloader/fuel_update_downloader/cli.py +++ b/fuel_upgrade_system/fuel_update_downloader/fuel_update_downloader/cli.py @@ -24,7 +24,7 @@ from fuel_update_downloader import errors def handle_exception(exc): if isinstance(exc, errors.FuelUpgradeException): - sys.stderr.write(str(exc) + "\n") + sys.stderr.write(exc.message + "\n") sys.exit(-1) else: traceback.print_exc(exc) diff --git a/fuel_upgrade_system/fuel_update_downloader/fuel_update_downloader/downloader.py b/fuel_upgrade_system/fuel_update_downloader/fuel_update_downloader/downloader.py index d9e0f0cb73..2b7d6ab5eb 100644 --- a/fuel_upgrade_system/fuel_update_downloader/fuel_update_downloader/downloader.py +++ b/fuel_upgrade_system/fuel_update_downloader/fuel_update_downloader/downloader.py @@ -53,7 +53,7 @@ class Downloader(object): free_space = calculate_free_space(self.dst_path) if free_space < self.required_free_space: raise errors.NotEnoughFreeSpace( - 'Not enough free space, path - "{0}", ' + u'Not enough free space, path - "{0}", ' 'free space - "{1}", ' 'required free space - "{2}"'.format( self.dst_path, free_space, self.required_free_space)) @@ -66,6 +66,6 @@ class Downloader(object): calculated_checksum = calculate_md5sum(self.dst_path) if calculated_checksum != self.checksum: raise errors.WrongChecksum( - 'File "{0}" has wrong checkum, actual ' + u'File "{0}" has wrong checkum, actual ' 'checksum "{1}" expected checksum "{2}"'.format( self.dst_path, calculated_checksum, self.checksum)) diff --git a/fuel_upgrade_system/fuel_update_downloader/setup.py b/fuel_upgrade_system/fuel_update_downloader/setup.py index dde51d357c..060cb9948a 100644 --- a/fuel_upgrade_system/fuel_update_downloader/setup.py +++ b/fuel_upgrade_system/fuel_update_downloader/setup.py @@ -22,7 +22,7 @@ from setuptools import setup def find_requires(): dir_path = os.path.dirname(os.path.realpath(__file__)) requirements = [] - with open('{0}/requirements.txt'.format(dir_path), 'r') as reqs: + with open(u'{0}/requirements.txt'.format(dir_path), 'r') as reqs: requirements = reqs.readlines() return requirements diff --git a/fuel_upgrade_system/fuel_upgrade/bin/fuel-upgrade b/fuel_upgrade_system/fuel_upgrade/bin/fuel-upgrade deleted file mode 100755 index ff162e619d..0000000000 --- a/fuel_upgrade_system/fuel_upgrade/bin/fuel-upgrade +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2014 Mirantis, Inc. -# -# 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 os -import sys - - -sys.path[:0] = [os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))] - - -from fuel_upgrade.cli import main - - -if __name__ == '__main__': - main() diff --git a/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/cli.py b/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/cli.py index 0ee52ce603..9dfd69e98f 100644 --- a/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/cli.py +++ b/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/cli.py @@ -14,16 +14,14 @@ # License for the specific language governing permissions and limitations # under the License. -from fuel_upgrade.logger import configure_logger - -# TODO(eli): move to config -logger = configure_logger('/tmp/file.log') - - import argparse import sys import traceback +from fuel_upgrade.logger import configure_logger +# TODO(eli): move to config +logger = configure_logger('/tmp/file.log') + from fuel_upgrade import errors from fuel_upgrade.upgrade import PuppetUpgrader from fuel_upgrade.upgrade import Upgrade @@ -31,8 +29,7 @@ from fuel_upgrade.upgrade import Upgrade def handle_exception(exc): if isinstance(exc, errors.FuelUpgradeException): - err_msg = str(exc) - logger.error(err_msg) + logger.error(exc.message) sys.exit(-1) else: traceback.print_exc(exc) diff --git a/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/upgrade.py b/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/upgrade.py index cf02e48c2d..3fe272564e 100644 --- a/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/upgrade.py +++ b/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/upgrade.py @@ -15,10 +15,9 @@ # under the License. import logging +import os import traceback -from os import path - from fuel_upgrade.utils import exec_cmd logger = logging.getLogger(__name__) @@ -33,8 +32,10 @@ class PuppetUpgrader(object): puppet_modules_dir = 'puppet_modules' def __init__(self, update_path): - puppet_modules_path = path.join(update_path, self.puppet_modules_dir) - self.puppet_cmd = 'puppet apply --debug --modulepath={0} -e '.format( + puppet_modules_path = os.path.join( + update_path, self.puppet_modules_dir) + + self.puppet_cmd = u'puppet apply --debug --modulepath={0} -e '.format( puppet_modules_path) def upgrade(self): @@ -58,7 +59,7 @@ class Upgrade(object): disable_rollback=False): logger.debug( - 'Create Upgrade object with update path "{0}", ' + u'Create Upgrade object with update path "{0}", ' 'working directory "{1}", ' 'upgrade engine "{2}", ' 'disable rollback is "{3}"'.format( @@ -78,7 +79,7 @@ class Upgrade(object): self.upgrade() self.after_upgrade() except Exception as exc: - logger.error('Upgrade failed: {0}'.format(exc)) + logger.error(u'Upgrade failed: {0}'.format(exc)) logger.error(traceback.format_exc()) if not self.disable_rollback: self.rollback() diff --git a/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/utils.py b/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/utils.py index 5b0f56f9a6..e7899e81f3 100644 --- a/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/utils.py +++ b/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/utils.py @@ -30,13 +30,13 @@ def exec_cmd(cmd): :param cmd: shell command :raises: ExecutedErrorNonZeroExitCode """ - logger.debug('Execute command "{0}"'.format(cmd)) + logger.debug(u'Execute command "{0}"'.format(cmd)) child = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - logger.debug('Stdout and stderr of command "{0}":'.format(cmd)) + logger.debug(u'Stdout and stderr of command "{0}":'.format(cmd)) for line in child.stdout: logger.debug(line.rstrip()) @@ -45,7 +45,7 @@ def exec_cmd(cmd): if return_code != 0: raise errors.ExecutedErrorNonZeroExitCode( - 'Shell command executed with "{0}" ' + u'Shell command executed with "{0}" ' 'exit code: {1} '.format(return_code, cmd)) - logger.debug('Command "{0}" successfully executed'.format(cmd)) + logger.debug(u'Command "{0}" successfully executed'.format(cmd)) diff --git a/fuel_upgrade_system/fuel_upgrade/setup.py b/fuel_upgrade_system/fuel_upgrade/setup.py index 8b9b03ded8..a7b77714c7 100644 --- a/fuel_upgrade_system/fuel_upgrade/setup.py +++ b/fuel_upgrade_system/fuel_upgrade/setup.py @@ -22,7 +22,7 @@ from setuptools import setup def find_requires(): dir_path = os.path.dirname(os.path.realpath(__file__)) requirements = [] - with open('{0}/requirements.txt'.format(dir_path), 'r') as reqs: + with open(u'{0}/requirements.txt'.format(dir_path), 'r') as reqs: requirements = reqs.readlines() return requirements