Repository: ambari
Updated Branches:
  refs/heads/trunk bc9097b14 -> 83f8add98


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/83f8add9
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/83f8add9
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/83f8add9

Branch: refs/heads/trunk
Commit: 83f8add98a1d6c4eb4f21069492f905f93c28f5b
Parents: bc9097b
Author: Andrew Onishuk <[email protected]>
Authored: Mon Jun 6 18:04:24 2016 +0300
Committer: Andrew Onishuk <[email protected]>
Committed: Mon Jun 6 18:04:24 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/83f8add9/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)
 

Reply via email to