]> git-server-git.apps.pok.os.sepia.ceph.com Git - ragweed.git/commitdiff
ragweed: more python3 changes
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 18 Dec 2019 15:51:42 +0000 (07:51 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 18 Dec 2019 15:51:42 +0000 (07:51 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
ragweed/framework.py
ragweed/reqs.py
requirements.txt
setup.py

index 802f9ddff4b0e7a3305dcbe2a09d07e2fa34a3d4..9fa733508daefa3f870e5fd4737bfd0f0237f7c9 100644 (file)
@@ -5,7 +5,7 @@ import boto.s3.connection
 import json
 import inspect
 import pickle
-import bunch
+import munch
 import yaml
 import configparser
 from boto.s3.key import Key
@@ -47,7 +47,7 @@ class RGWRESTAdmin:
         r = _make_admin_request(self.conn, "GET", path, params)
         if r.status != 200:
             raise boto.exception.S3ResponseError(r.status, r.reason)
-        return bunch.bunchify(json.loads(r.read()))
+        return munch.munchify(json.loads(r.read()))
 
 
     def read_meta_key(self, key):
@@ -125,7 +125,7 @@ class RSuite:
 
 class RTestJSONSerialize(json.JSONEncoder):
     def default(self, obj):
-        if isinstance(obj, (list, dict, str, unicode, int, float, bool, type(None))):
+        if isinstance(obj, (list, dict, str, int, float, bool, type(None))):
             return JSONEncoder.default(self, obj)
         return {'__pickle': pickle.dumps(obj)}
 
@@ -200,7 +200,7 @@ class RStorageClasses:
             self.storage_classes = config.storage_classes
         else:
             try:
-                self.storage_classes = bunch.bunchify({ 'STANDARD': { 'data_pool': config.data_pool }})
+                self.storage_classes = munch.munchify({ 'STANDARD': { 'data_pool': config.data_pool }})
             except:
                 self.storage_classes = None
                 pass
@@ -217,7 +217,7 @@ class RStorageClasses:
         return sc
 
     def get_all(self):
-        for (name, _) in self.storage_classes.iteritems():
+        for (name, _) in self.storage_classes.items():
             yield name
 
 class RPlacementTarget:
@@ -345,11 +345,11 @@ class RTest:
             self.check()
 
 def read_config(fp):
-    config = bunch.Bunch()
+    config = munch.Munch()
     g = yaml.safe_load_all(fp)
     for new in g:
-        print(bunch.bunchify(new))
-        config.update(bunch.bunchify(new))
+        print(munch.munchify(new))
+        config.update(munch.munchify(new))
     return config
 
 str_config_opts = [
@@ -370,13 +370,13 @@ bool_config_opts = [
                 ]
 
 def dict_find(d, k):
-    if d.has_key(k):
+    if k in d:
         return d[k]
     return None
 
 class RagweedEnv:
     def __init__(self):
-        self.config = bunch.Bunch()
+        self.config = munch.Munch()
 
         cfg = configparser.RawConfigParser()
         try:
@@ -392,17 +392,17 @@ class RagweedEnv:
         for section in cfg.sections():
             try:
                 (section_type, name) = section.split(None, 1)
-                if not self.config.has_key(section_type):
-                    self.config[section_type] = bunch.Bunch()
-                self.config[section_type][name] = bunch.Bunch()
+                if not section_type in self.config:
+                    self.config[section_type] = munch.Munch()
+                self.config[section_type][name] = munch.Munch()
                 cur = self.config[section_type]
             except ValueError:
                 section_type = ''
                 name = section
-                self.config[name] = bunch.Bunch()
+                self.config[name] = munch.Munch()
                 cur = self.config
 
-            cur[name] = bunch.Bunch()
+            cur[name] = munch.Munch()
 
             for var in str_config_opts:
                 try:
@@ -431,8 +431,8 @@ class RagweedEnv:
         except:
             self.bucket_prefix = 'ragweed'
 
-        conn = bunch.Bunch()
-        for (k, u) in self.config.user.iteritems():
+        conn = munch.Munch()
+        for (k, u) in self.config.user.items():
             conn[k] = RGWConnection(u.access_key, u.secret_key, rgw_conf.host, dict_find(rgw_conf, 'port'), dict_find(rgw_conf, 'is_secure'))
 
         self.zone = RZone(conn)
index 2f7c57dde485c81f2b44bc26a0855128a557ac0f..f066506cfcc425abba6fbdfb69ee7bfb598384af 100644 (file)
@@ -1,7 +1,6 @@
 import boto.s3.connection
 from http.client import HTTPConnection, HTTPSConnection
-from urllib.parse import urlparse
-import urllib
+from urllib.parse import urlparse, urlencode
 
 def _make_admin_request(conn, method, path, query_dict=None, body=None, response_headers=None, request_headers=None, expires_in=100000, path_style=True, timeout=None):
     """
@@ -12,7 +11,7 @@ def _make_admin_request(conn, method, path, query_dict=None, body=None, response
 
     query = ''
     if query_dict is not None:
-        query = urllib.urlencode(query_dict)
+        query = urlencode(query_dict)
 
     (bucket_str, key_str) = path.split('/', 2)[1:]
     bucket = conn.get_bucket(bucket_str, validate=False)
@@ -97,7 +96,7 @@ def _make_raw_request(host, port, method, path, body=None, request_headers=None,
     if request_headers is None:
         request_headers = {}
 
-    c = class_(host, port, strict=True, timeout=timeout)
+    c = class_(host, port, timeout=timeout)
 
     # TODO: We might have to modify this in future if we need to interact with
     # how http.client.request handles Accept-Encoding and Host.
index a059565e378da489670949a1c3b1f3e6b15b2b1f..178ef67966ca8e5a98545a2621664c745472c90a 100644 (file)
@@ -1,7 +1,7 @@
 PyYAML
 nose >=1.0.0
 boto >=2.6.0, != 2.46.0
-bunch >=1.0.0
+munch >=1.0.0
 gevent >=1.0
 httplib2
 lxml
index 381467c5ef539e0706ca7b5fc036ab866d1ee98e..7ee3825961b8884e4e430650a7ae43c46828e8e0 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -15,7 +15,7 @@ setup(
     install_requires=[
         'boto >=2.0b4',
         'PyYAML',
-        'bunch >=1.0.0',
+        'munch >=1.0.0',
         'gevent >=1.0',
         'isodate >=0.4.4',
         ],