Repository: ambari Updated Branches: refs/heads/branch-2.4 07bec49de -> 02d36acb2
AMBARI-17061. [ambari] ambari-agent restart is failing due to unsupported locale setting (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/02d36acb Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/02d36acb Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/02d36acb Branch: refs/heads/branch-2.4 Commit: 02d36acb2aa2cfa6e1de3e9b0927e08c7b9b6ebf Parents: 07bec49 Author: Andrew Onishuk <[email protected]> Authored: Mon Jun 6 17:50:56 2016 +0300 Committer: Andrew Onishuk <[email protected]> Committed: Mon Jun 6 17:50:56 2016 +0300 ---------------------------------------------------------------------- ambari-agent/src/main/python/ambari_agent/main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/02d36acb/ambari-agent/src/main/python/ambari_agent/main.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/python/ambari_agent/main.py b/ambari-agent/src/main/python/ambari_agent/main.py index 32e522d..201264c 100644 --- a/ambari-agent/src/main/python/ambari_agent/main.py +++ b/ambari-agent/src/main/python/ambari_agent/main.py @@ -27,6 +27,7 @@ import traceback import getpass import os import time +import locale import platform import ConfigParser import ProcessHelper @@ -49,10 +50,6 @@ from resource_management.core.logger import Logger logger = logging.getLogger() alerts_logger = logging.getLogger('ambari_alerts') -# use the host's locale for numeric formatting -import locale -locale.setlocale(locale.LC_ALL, '') - formatstr = "%(levelname)s %(asctime)s %(filename)s:%(lineno)d - %(message)s" agentPid = os.getpid() config = AmbariConfig.AmbariConfig() @@ -268,6 +265,12 @@ def main(heartbeat_stop_callback=None): setup_logging(alerts_logger, AmbariConfig.AmbariConfig.getAlertsLogFile(), logging_level) Logger.initialize_logger('resource_management', logging_level=logging_level) + # use the host's locale for numeric formatting + try: + locale.setlocale(locale.LC_ALL, '') + except locale.Error as ex: + logger.warning("Cannot set locale for ambari-agent. Please check your systemwide locale settings. Failed due to: {0}.".format(str(ex))) + default_cfg = {'agent': {'prefix': '/home/ambari'}} config.load(default_cfg)
