#61 Clean code, fix rhel7
Merged 2 years ago by tdawson. Opened 2 years ago by tdawson.
centos/ tdawson/centpkg rhel7-fix  into  develop

file modified
-2
@@ -3,8 +3,6 @@ 

  lookasidehash = sha512

  lookaside_cgi = https://git.centos.org/sources/upload_sig.cgi

  # lookaside_cgi = https://git.centos.org/sources/upload.cgi

- lookaside_structure = hash

- # lookaside_structure = branch

  distgit_namespaced = True

  distgit_namespaces = rpms

  gitbaseurl = ssh://git@git.centos.org/%(repo)s.git

file modified
+1 -11
@@ -153,11 +153,6 @@ 

          # should only be used when configured for SHA512

          self.source_entry_type = 'bsd' if self.lookasidehash != 'md5' else 'old'

          self.branchre = 'c\d{1,}(s)?(tream)?|master'

-         self.lookaside_structure = None

- 

-     def update(self, config):

-         if self.lookaside_structure is None:

-             self.lookaside_structure = config.get('lookaside_structure', 'hash')

  

      @property

      def distgitdir(self):
@@ -172,17 +167,12 @@ 

                                          )

          else:

              if self.distgitdir.sigbranch:

-                 self.log.info("    Centpkg: Commands lookasidecache: SIGLookasideCache")

-                 self.log.info("        lookaside_structure " + self.lookaside_structure)

                  return SIGLookasideCache(self.lookasidehash,

                                          self.lookaside,

                                          self.lookaside_cgi,

                                          self.repo_name,

-                                         self.branch_merge,

-                                         structure=self.lookaside_structure)

+                                         self.branch_merge)

              else:

-                 self.log.info("    Centpkg: Commands lookasidecache: CLLookasideCache")

-                 self.log.info("        lookaside_structure " + self.lookaside_structure)

                  return CLLookasideCache(self.lookasidehash,

                                              self.lookaside,

                                              self.lookaside_cgi,

file modified
-5
@@ -35,11 +35,6 @@ 

  

          self.setup_centos_subparsers()

  

-     def load_cmd(self):

-         super(centpkgClient, self).load_cmd()

-         cfg = self.config[self.get_name()]

-         self._cmd.update(cfg)

- 

      def setup_centos_subparsers(self):

          self.register_do_fork()

          self.register_request_gated_side_tag()

file modified
+16 -27
@@ -94,7 +94,7 @@ 

          return super(StreamLookasideCache, self).remote_file_exists(

                  _name, filename, hashstr)

  

-     def upload(self, name, filename, hashstr, offline=False, **kwargs):

+     def upload(self, name, filename, hashstr, offline=False):

          """

          Uploads a file to lookaside cache.

  
@@ -178,14 +178,11 @@ 

      def __init__(self, hashtype, download_url, upload_url, name, branch):

          super(CLLookasideCache, self).__init__(

              hashtype, download_url, upload_url, name, branch)

-         self.log.info("  Centpkg: CLLookasideCache __init__")

          self.name = name

          self.branch = branch

  

      def get_download_url(self, name, filename, hash, hashtype=None, **kwargs):

-         print("  Centpkg: CLLookasideCache get_download_url")

          self.download_path='%(name)s/%(branch)s/%(hash)s'

-         print("    Centpkg: CLLookasideCache get_download_url download_path: " + self.download_path)

          if "/" in name:

                  real_name = name.split("/")[-1]

          else:
@@ -207,32 +204,28 @@ 

  

      It inherits most of its behavior from `pyrpkg.lookasideCGILookasideCache`.

      """

-     def __init__(self, hashtype, download_url, upload_url, name, branch, structure='hash', client_cert=None, ca_cert=None):

+     def __init__(self, hashtype, download_url, upload_url, name, branch, client_cert=None, ca_cert=None):

          super(SIGLookasideCache, self).__init__(

              hashtype, download_url, upload_url, client_cert=client_cert, ca_cert=ca_cert)

  

          self.name = name

          self.branch = branch

-         self.structure = structure

  

      def get_download_url(self, name, filename, hash, hashtype=None, **kwargs):

-         if self.structure == 'hash':

-             download_path =  '%(name)s/%(branch)s/%(hash)s'

-             if "/" in name:

-                     real_name = name.split("/")[-1]

-             else:

-                     real_name = name

-             path_dict = {

-                     'name': real_name,

-                     'filename': filename,

-                     'branch': self.branch,

-                     'hash': hash,

-                     'hashtype': hashtype

-             }

-             path = download_path % path_dict

-             return os.path.join(self.download_url, path)

- 

-         return super(SIGLookasideCache, self).get_download_url(name, filename, hash, hashtype, **kwargs)

+         download_path =  '%(name)s/%(branch)s/%(hash)s'

+         if "/" in name:

+                 real_name = name.split("/")[-1]

+         else:

+                 real_name = name

+         path_dict = {

+                 'name': real_name,

+                 'filename': filename,

+                 'branch': self.branch,

+                 'hash': hash,

+                 'hashtype': hashtype

+         }

+         path = download_path % path_dict

+         return os.path.join(self.download_url, path)

  

      def remote_file_exists(self, name, filename, hash):

          """Verify whether a file exists on the lookaside cache
@@ -259,8 +252,6 @@ 

          post_data = [('name', _name),

                       ('%ssum' % self.hashtype, hash),

                       ('filename', filename)]

-         if self.structure == 'branch':

-             post_data.append(('branch', self.branch))

  

          with io.BytesIO() as buf:

              c = pycurl.Curl()
@@ -338,8 +329,6 @@ 

          post_data = [('name', name),

                       ('%ssum' % self.hashtype, hash),

                       ('file', (pycurl.FORM_FILE, filepath))]

-         if self.structure == 'branch':

-             post_data.append(('branch', self.branch))

  

          with io.BytesIO() as buf:

              c = pycurl.Curl()

One of the past commits broke centpkg on RHEL 7 based systems, that use python2.
This commit fixes centpkg on RHEL 7 systems, as well as clean up some of the other code.

Signed-off-by: Troy Dawson tdawson@redhat.com

Pull-Request has been merged by tdawson

2 years ago