Przeglądaj źródła

HUE-8737 [core] Futurize desktop/libs/libzookeeper for Python 3.5

Ying Chen 6 lat temu
rodzic
commit
b368a07152

+ 8 - 2
desktop/libs/libzookeeper/src/libzookeeper/conf.py

@@ -15,12 +15,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from future import standard_library
+standard_library.install_aliases()
 import logging
-
-from urlparse import urlparse
+import sys
 
 from desktop.lib.conf import Config, coerce_string
 
+if sys.version_info[0] > 2:
+  from urllib.parse import urlparse
+  new_str = str
+else:
+  from urlparse import urlparse
 
 LOG = logging.getLogger(__name__)
 

+ 1 - 0
desktop/libs/libzookeeper/src/libzookeeper/models.py

@@ -14,6 +14,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+from builtins import object
 import logging
 import os
 

+ 4 - 3
desktop/libs/libzookeeper/src/libzookeeper/tests.py

@@ -15,6 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from builtins import object
 import os
 import shutil
 import tempfile
@@ -32,7 +33,7 @@ from libzookeeper.models import ZookeeperClient
 from libzookeeper.conf import zkensemble, ENSEMBLE
 
 
-class UnitTests():
+class UnitTests(object):
 
   def test_get_ensemble(self):
     clear = ENSEMBLE.set_for_testing('zoo:2181')
@@ -54,7 +55,7 @@ class UnitTests():
       clear()
 
 
-class TestWithZooKeeper:
+class TestWithZooKeeper(object):
   requires_hadoop = True
   integration = True
 
@@ -77,7 +78,7 @@ class TestWithZooKeeper:
     # Create subdirectory
     cls.subdir_name = 'subdir'
     subdir_path = '%s/%s' % (cls.local_directory, cls.subdir_name)
-    os.mkdir(subdir_path, 0755)
+    os.mkdir(subdir_path, 0o755)
     # Create file
     cls.filename = 'test.txt'
     file_path = '%s/%s' % (subdir_path, cls.filename)