Ver Fonte

HUE-8737 [fb] Fix file browser for Python 3.5

Ying Chen há 6 anos atrás
pai
commit
9a92dc1208

+ 1 - 1
apps/filebrowser/src/filebrowser/views.py

@@ -225,7 +225,7 @@ def view(request, path):
     except (IOError, WebHdfsException) as e:
         msg = _("Cannot access: %(path)s. ") % {'path': escape(path)}
 
-        if "Connection refused" in e.message:
+        if "Connection refused" in e.args[0]:
             msg += _(" The HDFS REST service is not available. ")
 
         if request.is_ajax():

+ 1 - 1
desktop/core/src/desktop/lib/i18n.py

@@ -67,7 +67,7 @@ def force_unicode(s, strings_only=False, errors='strict'):
   Wrapper around Django's version, while supplying our configured encoding.
   Decode char array to unicode.
   """
-  return django.utils.encoding.force_unicode(
+  return django.utils.encoding.force_text(
         s, get_site_encoding(), strings_only, errors)
 
 def smart_str(s, strings_only=False, errors='strict'):

+ 7 - 1
desktop/libs/hadoop/src/hadoop/core_site.py

@@ -18,12 +18,18 @@
 from __future__ import absolute_import
 import errno
 import logging
+import sys
 
 from hadoop import conf
 from hadoop import confparse
 
 from desktop.lib.paths import get_config_root_hadoop
 
+if sys.version_info[0] > 2:
+  open_file = open
+else:
+  open_file = file
+
 __all = ['get_conf', 'get_trash_interval', 'get_s3a_access_key', 'get_s3a_secret_key']
 
 LOG = logging.getLogger(__name__)
@@ -66,7 +72,7 @@ def _parse_core_site():
 
   try:
     _CORE_SITE_PATH = get_config_root_hadoop('core-site.xml')
-    data = file(_CORE_SITE_PATH, 'r').read()
+    data = open_file(_CORE_SITE_PATH, 'r').read()
   except IOError as err:
     if err.errno != errno.ENOENT:
       LOG.error('Cannot read from "%s": %s' % (_CORE_SITE_PATH, err))