Browse Source

[py3] Fix error when start Hue shell on command line (#2947)

Ying Chen 3 years ago
parent
commit
c0fd538ac1
1 changed files with 8 additions and 5 deletions
  1. 8 5
      desktop/core/src/desktop/manage_entry.py

+ 8 - 5
desktop/core/src/desktop/manage_entry.py

@@ -110,7 +110,7 @@ def entry():
     else:
     else:
       from ConfigParser import NoOptionError, RawConfigParser
       from ConfigParser import NoOptionError, RawConfigParser
 
 
-    config = RawConfigParser()
+    config = RawConfigParser(strict=False) if sys.version_info[0] > 2 else RawConfigParser()
     config.read(cm_config_file)
     config.read(cm_config_file)
     try:
     try:
       cm_agent_run_dir = config.get('General', 'agent_wide_credential_cache_location')
       cm_agent_run_dir = config.get('General', 'agent_wide_credential_cache_location')
@@ -162,7 +162,8 @@ def entry():
       print("If the above does not work, make sure Hue has been started on this server.")
       print("If the above does not work, make sure Hue has been started on this server.")
 
 
     if not envline == None:
     if not envline == None:
-      empty, environment = envline.split("environment=")
+      # spliting envline by "environment=" won't work since new key cdp_environment was added
+      environment = envline.replace("environment=", "")
       for envvar in environment.split(","):
       for envvar in environment.split(","):
         include_env_vars = ("HADOOP_C", "PARCEL", "SCM_DEFINES", "LD_LIBRARY")
         include_env_vars = ("HADOOP_C", "PARCEL", "SCM_DEFINES", "LD_LIBRARY")
         if any(include_env_var in envvar for include_env_var in include_env_vars):
         if any(include_env_var in envvar for include_env_var in include_env_vars):
@@ -186,9 +187,11 @@ def entry():
       JAVA_HOME = "UNKNOWN"
       JAVA_HOME = "UNKNOWN"
 
 
       if locate_java is not None:
       if locate_java is not None:
-        for line in iter(locate_java.stdout.readline, ''):
-          if 'JAVA_HOME' in line:
-            JAVA_HOME = line.rstrip().split('=')[1]
+        for line in iter(locate_java.stdout.readline, b''):
+          if b'JAVA_HOME' in line:
+            JAVA_HOME = line.rstrip().split(b'=')[1]
+            if sys.version_info[0] > 2 and type(JAVA_HOME) == bytes:
+              JAVA_HOME = JAVA_HOME.decode("utf-8")
 
 
       if JAVA_HOME != "UNKNOWN":
       if JAVA_HOME != "UNKNOWN":
         os.environ["JAVA_HOME"] = JAVA_HOME
         os.environ["JAVA_HOME"] = JAVA_HOME