瀏覽代碼

AMBARI-6674. potential language/encoding problem with mysql (aonishuk)

Andrew Onishuk 10 年之前
父節點
當前提交
68b97f0355

+ 1 - 1
ambari-agent/src/main/python/resource_management/core/logger.py

@@ -89,4 +89,4 @@ class Logger:
     if arguments_str:  
       arguments_str = arguments_str[:-2]
     
-    return "{0} {{{1}}}".format(resource, arguments_str)
+    return unicode("{0} {{{1}}}").format(resource, arguments_str)

+ 2 - 2
ambari-agent/src/main/python/resource_management/core/providers/system.py

@@ -100,7 +100,7 @@ class FileProvider(Provider):
     elif self.resource.replace:
       if content is not None:
         with open(path, "rb") as fp:
-          old_content = fp.read()
+          old_content = fp.read().decode("UTF-8")
         if content != old_content:
           write = True
           reason = "contents don't match"
@@ -111,7 +111,7 @@ class FileProvider(Provider):
       Logger.info("Writing %s because %s" % (self.resource, reason))
       with open(path, "wb") as fp:
         if content:
-          fp.write(content)
+          fp.write(content.encode("UTF-8"))
 
     _ensure_metadata(self.resource.path, self.resource.owner,
                         self.resource.group, mode=self.resource.mode)

+ 1 - 1
ambari-agent/src/main/python/resource_management/libraries/functions/format.py

@@ -66,7 +66,7 @@ class ConfigurationFormatter(Formatter):
   
   def _convert_field(self, value, conversion, is_protected):
     if conversion == 'e':
-      return quote_bash_args(str(value))
+      return quote_bash_args(unicode(value))
     elif conversion == 'h':
       return "[PROTECTED]" if is_protected else value
     elif conversion == 'p':