From e71d8b21f717b7bfeff0fe31a47d7eb47123a061 Mon Sep 17 00:00:00 2001
From: Tomas Kopecek <tkopecek@redhat.com>
Date: Mar 14 2018 10:51:48 +0000
Subject: make py2 files parseable with py3


---

diff --git a/builder/kojid b/builder/kojid
index 726d535..4b1833e 100755
--- a/builder/kojid
+++ b/builder/kojid
@@ -434,7 +434,7 @@ class BuildRoot(object):
                 if workdir:
                     outfile = os.path.join(workdir, mocklog)
                     flags = os.O_CREAT | os.O_WRONLY | os.O_APPEND
-                    fd = os.open(outfile, flags, 0666)
+                    fd = os.open(outfile, flags, 0o666)
                     os.dup2(fd, 1)
                     os.dup2(fd, 2)
                 if os.getuid() == 0 and hasattr(self.options,"mockuser"):
@@ -1392,7 +1392,7 @@ class BuildMavenTask(BaseBuildTask):
                     st = os.lstat(filepath)
                     mtime = time.localtime(st.st_mtime)
                     info = zipfile.ZipInfo(filepath[roottrim:])
-                    info.external_attr |= 0120000 << 16L # symlink file type
+                    info.external_attr |= 0o120000 << 16 # symlink file type
                     info.compress_type = zipfile.ZIP_STORED
                     info.date_time = mtime[:6]
                     zfo.writestr(info, content)
@@ -2039,7 +2039,7 @@ class ChainMavenTask(MultiPlatformTask):
                 del todo[package]
             try:
                 results = self.wait(running.keys())
-            except (xmlrpclib.Fault, koji.GenericError), e:
+            except (xmlrpclib.Fault, koji.GenericError) as e:
                 # One task has failed, wait for the rest to complete before the
                 # chainmaven task fails.  self.wait(all=True) should thrown an exception.
                 self.wait(all=True)
@@ -2176,7 +2176,7 @@ class TagBuildTask(BaseTaskHandler):
             #XXX - add more post tests
             self.session.host.tagBuild(self.id,tag_id,build_id,force=force,fromtag=fromtag)
             self.session.host.tagNotification(True, tag_id, fromtag, build_id, user_id, ignore_success)
-        except Exception, e:
+        except Exception as e:
             exctype, value = sys.exc_info()[:2]
             self.session.host.tagNotification(False, tag_id, fromtag, build_id, user_id, ignore_success, "%s: %s" % (exctype, value))
             raise e
@@ -2746,10 +2746,10 @@ class ImageTask(BaseTaskHandler):
         self.ks = ksparser.KickstartParser(version)
         try:
             self.ks.readKickstart(kspath)
-        except IOError, e:
+        except IOError as e:
             raise koji.LiveCDError("Failed to read kickstart file "
                                    "'%s' : %s" % (kspath, e))
-        except kserrors.KickstartError, e:
+        except kserrors.KickstartError as e:
             raise koji.LiveCDError("Failed to parse kickstart file "
                                     "'%s' : %s" % (kspath, e))
 
@@ -3411,10 +3411,10 @@ class OzImageTask(BaseTaskHandler):
         self.logger.debug('attempting to read kickstart: %s' % kspath)
         try:
             ks.readKickstart(kspath)
-        except IOError, e:
+        except IOError as e:
             raise koji.BuildError("Failed to read kickstart file "
                                    "'%s' : %s" % (kspath, e))
-        except kserrors.KickstartError, e:
+        except kserrors.KickstartError as e:
             raise koji.BuildError("Failed to parse kickstart file "
                                     "'%s' : %s" % (kspath, e))
         return ks
@@ -4355,7 +4355,7 @@ class BuildIndirectionImageTask(OzImageTask):
                 base_factory_image = _nvr_to_image(opts['base_image_build'], opts['arch'])
             else:
                 base_factory_image = _task_to_image(int(opts['base_image_task']))
-        except Exception, e:
+        except Exception as e:
             self.logger.exception(e)
             raise
 
@@ -4417,7 +4417,7 @@ class BuildIndirectionImageTask(OzImageTask):
                         image_id=base_factory_image.identifier,
                         parameters=params)
                     target.target_thread.join()
-            except Exception, e:
+            except Exception as e:
                 self.logger.debug("Exception encountered during target build")
                 self.logger.exception(e)
         finally:
@@ -5770,7 +5770,7 @@ if __name__ == "__main__":
             # authenticate using SSL client certificates
             session.ssl_login(options.cert, None,
                               options.serverca)
-        except koji.AuthError, e:
+        except koji.AuthError as e:
             quit("Error: Unable to log in: %s" % e)
         except xmlrpclib.ProtocolError:
             quit("Error: Unable to connect to server %s" % (options.server))
@@ -5790,9 +5790,9 @@ if __name__ == "__main__":
             session.krb_login(principal=krb_principal,
                               keytab=options.keytab,
                               ccache=options.ccache)
-        except krbV.Krb5Error, e:
+        except krbV.Krb5Error as e:
             quit("Kerberos authentication failed: '%s' (%s)" % (e.args[1], e.args[0]))
-        except socket.error, e:
+        except socket.error as e:
             quit("Could not connect to Kerberos authentication service: '%s'" % e.args[1])
     else:
         quit("No username/password supplied and Kerberos missing or not configured")
diff --git a/koji/tasks.py b/koji/tasks.py
index 6d5a000..070736c 100644
--- a/koji/tasks.py
+++ b/koji/tasks.py
@@ -122,18 +122,18 @@ def parse_task_params(method, params):
     args, kwargs = koji.decode_args(*params)
 
     if method not in LEGACY_SIGNATURES:
-        raise TypeError, "No legacy signature for %s" % method
+        raise TypeError("No legacy signature for %s" % method)
 
     err = None
     for argspec in LEGACY_SIGNATURES[method]:
         try:
             params = koji.util.apply_argspec(argspec, args, kwargs)
             break
-        except koji.ParameterError, e:
+        except koji.ParameterError as e:
             if not err:
                 err = e.message
     else:
-        raise koji.ParameterError, "Invalid signature for %s: %s" % (method, err)
+        raise koji.ParameterError("Invalid signature for %s: %s" % (method, err))
 
     return params
 

