From decb4cb8d481f8d05a1cdb36fd12bcbf36a6772a Mon Sep 17 00:00:00 2001
From: Marco Clemencic <marco.clemencic@cern.ch>
Date: Mon, 22 Mar 2021 09:49:59 +0100
Subject: [PATCH] Make code Python3 compatible

---
 .gitlab-ci.yml                   | 2 +-
 LbAdmin/CreateAllSpecs.py        | 2 +-
 LbAdmin/CreateLHCbLCGMetaSpec.py | 2 +-
 LbAdmin/LbDeploymentUpdateSdb.py | 2 +-
 LbAdmin/RpmRelease.py            | 4 ++--
 setup.py                         | 9 ++++-----
 6 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 00666f5..897129f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,7 +9,7 @@ python3.7:
     - python --version
     - pip install -e .
     - python setup.py nosetests --cover-package ${CI_PROJECT_NAME}
-    - mkdir -p cover_report && mv -f build/lib/cover cover_report/$CI_JOB_NAME
+    - mkdir -p cover_report && mv -f cover cover_report/$CI_JOB_NAME
     - python setup.py sdist --dist-dir public/${CI_PROJECT_NAME,,}
     - python setup.py bdist_wheel --dist-dir public/${CI_PROJECT_NAME,,}
   artifacts:
diff --git a/LbAdmin/CreateAllSpecs.py b/LbAdmin/CreateAllSpecs.py
index b4757cf..0aad533 100644
--- a/LbAdmin/CreateAllSpecs.py
+++ b/LbAdmin/CreateAllSpecs.py
@@ -66,7 +66,7 @@ def main():
     for p in platforms:
         rpmname = args.name_template.format(lcg_version=lcg_version, platform=p)
         output = rpmname + ".spec"
-        f = createSpec(p, args.external_list_json, output , release=args.release,
+        f = createSpec(p, args.external_list_json, output, release=args.release,
                        rpmname=rpmname, rpmroot=args.buildroot)
         print("Created {}".format(f))
         specs.append(f)
diff --git a/LbAdmin/CreateLHCbLCGMetaSpec.py b/LbAdmin/CreateLHCbLCGMetaSpec.py
index 9b21c08..1388bc0 100644
--- a/LbAdmin/CreateLHCbLCGMetaSpec.py
+++ b/LbAdmin/CreateLHCbLCGMetaSpec.py
@@ -80,7 +80,7 @@ class VersionFinder(object):
         if lhcb_installer is None:
             lhcb_installer = Installer(self.siteroot)
         if self.packages is None:
-            self.packages = set([p.name for p in lhcb_installer.remoteListPackages('LCG_%s_' % self.lcgVersion)])
+            self.packages = {p.name for p in lhcb_installer.remoteListPackages('LCG_%s_' % self.lcgVersion)}
 
     def find(self, package):
         self.setup()
diff --git a/LbAdmin/LbDeploymentUpdateSdb.py b/LbAdmin/LbDeploymentUpdateSdb.py
index cdc0446..7d2fef3 100755
--- a/LbAdmin/LbDeploymentUpdateSdb.py
+++ b/LbAdmin/LbDeploymentUpdateSdb.py
@@ -149,7 +149,7 @@ class CheckReleasedConfig(Script):
                                      self.options.update,
                                      self.options.platform_regex,
                                      self.options.name_regex)
-        except Exception, e:
+        except Exception as e:
             self.log.error(e)
             rc = 1
         return rc
diff --git a/LbAdmin/RpmRelease.py b/LbAdmin/RpmRelease.py
index 3eb915e..8b1e05f 100644
--- a/LbAdmin/RpmRelease.py
+++ b/LbAdmin/RpmRelease.py
@@ -36,10 +36,10 @@ def ReSyncRepoJson(repopath,
     json_data = {}
     if os.path.exists(jsonFilePath):
         with open(jsonFilePath, "r") as f:
-            json_data = json.loads(f.read())
+            json_data = json.load(f)
     else:
         raise IOError("No json file found!")
-    for repo in json_data.keys():
+    for repo in json_data:
         repodir = json_data[repo]['url']
         # stripping end / as some servers (S3) cannot cope with multiple / 
         xml_repo_info_url = "%s/repodata/repomd.xml" % repodir.rstrip("/")
diff --git a/setup.py b/setup.py
index a063e59..aa62e94 100644
--- a/setup.py
+++ b/setup.py
@@ -100,6 +100,9 @@ setup(
         'Programming Language :: Python :: 3',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.7',
+        'Programming Language :: Python :: 3.8',
+        'Programming Language :: Python :: 3.9',
     ],
 
     python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4',
@@ -119,8 +122,7 @@ setup(
     #
     #   py_modules=["my_module"],
     #
-    packages=find_packages(exclude=['*.tests']
-                           if version_info < (3, 0) else []),
+    packages=find_packages(exclude=['*.tests']),
     #package=["LbAdmin"],
 
     # This field lists other packages that your project depends on to run.
@@ -181,7 +183,4 @@ setup(
 
     # The package can be safely distributed as a ZIP file
     zip_safe=True,
-
-    # Process files with 2to3 to run with Python 3
-    use_2to3=version_info >= (3, 0),
 )
-- 
GitLab