[projects/pld-builder.new] Fix outdated syntax

baggins baggins at pld-linux.org
Sun Feb 28 22:47:19 CET 2021


commit 5131e72930f3986dd82a660d6ba87b25920a7192
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Feb 28 22:45:51 2021 +0100

    Fix outdated syntax

 PLD_Builder/bqueue.py                 |  2 +-
 PLD_Builder/file_sender.py            |  4 ++--
 PLD_Builder/gpg.py                    |  6 +++---
 PLD_Builder/mailer.py                 |  2 +-
 PLD_Builder/request_fetcher.py        | 10 +++++-----
 PLD_Builder/request_handler_server.py |  4 ++--
 PLD_Builder/rpm_builder.py            | 20 ++++++++++----------
 client/make-request.sh                |  2 +-
 8 files changed, 25 insertions(+), 25 deletions(-)
---
diff --git a/PLD_Builder/bqueue.py b/PLD_Builder/bqueue.py
index 6169fcd..395e32f 100644
--- a/PLD_Builder/bqueue.py
+++ b/PLD_Builder/bqueue.py
@@ -96,7 +96,7 @@ class B_Queue:
             return
         try:
             self.requests = request.parse_requests(body)
-        except Exception, e:
+        except Exception as e:
             log.panic("error parsing %s: %s" % (self.name, e))
             pass
 
diff --git a/PLD_Builder/file_sender.py b/PLD_Builder/file_sender.py
index 44fdd8b..4e524c4 100644
--- a/PLD_Builder/file_sender.py
+++ b/PLD_Builder/file_sender.py
@@ -99,7 +99,7 @@ def post_file(src, url):
         req.add_header('X-Filename', os.path.basename(src))
         f = urllib2.urlopen(req)
         f.close()
-    except Exception, e:
+    except Exception as e:
         problems[src] = e
         return e
     return 0
@@ -123,7 +123,7 @@ def send_file(src, target):
         if m:
             return not post_file(src, target)
         log.alert("unsupported protocol: %s" % target)
-    except OSError, e:
+    except OSError as e:
         problems[src] = e
         log.error("send_file(%s, %s): %s" % (src, target, e))
         return False
diff --git a/PLD_Builder/gpg.py b/PLD_Builder/gpg.py
index 2b3af81..055c390 100644
--- a/PLD_Builder/gpg.py
+++ b/PLD_Builder/gpg.py
@@ -28,7 +28,7 @@ def get_keys(buf):
     gpg_run = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
     try:
         d_stdout, d_stderr = gpg_run.communicate(buf.encode('utf-8'))
-    except OSError, e:
+    except OSError as e:
         log.error("gnupg run, does gpg binary exist? : %s" % e)
         raise
 
@@ -60,7 +60,7 @@ def verify_sig(buf):
     gpg_run = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
     try:
         d_stdout, d_stderr = gpg_run.communicate(buf.encode('utf-8'))
-    except OSError, e:
+    except OSError as e:
         log.error("gnupg run failed, does gpg binary exist? : %s" % e)
         raise
 
@@ -86,7 +86,7 @@ def sign(buf):
     gpg_run = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
     try:
         d_stdout, d_stderr = gpg_run.communicate(buf.encode('utf-8'))
-    except OSError, e:
+    except OSError as e:
         log.error("gnupg signing failed, does gpg binary exist? : %s" % e)
         raise
 
diff --git a/PLD_Builder/mailer.py b/PLD_Builder/mailer.py
index 4e771dc..56a9f14 100644
--- a/PLD_Builder/mailer.py
+++ b/PLD_Builder/mailer.py
@@ -88,7 +88,7 @@ class Message:
         f = os.popen(send_sendmail, "w")
         try:
             self.write_to(f)
-        except IOError, e:
+        except IOError as e:
             log.alert("sending email message failed: %s" % e)
             f.close()
             return False
diff --git a/PLD_Builder/request_fetcher.py b/PLD_Builder/request_fetcher.py
index dc87607..6122612 100644
--- a/PLD_Builder/request_fetcher.py
+++ b/PLD_Builder/request_fetcher.py
@@ -36,7 +36,7 @@ def has_new(control_url):
     cnt_f = open(path.last_req_no_file)
     try:
         last_count = int(string.strip(cnt_f.readline()))
-    except ValueError, e:
+    except ValueError as e:
         last_count = 0
 
     cnt_f.close()
@@ -50,7 +50,7 @@ def has_new(control_url):
         f = urllib2.urlopen(req)
         count = int(string.strip(f.readline()))
         signal.alarm(0)
-    except Exception, e:
+    except Exception as e:
         signal.alarm(0)
         log.error("can't fetch %s: %s" % (control_url + "/max_req_no", e))
         sys.exit(1)
@@ -69,7 +69,7 @@ def fetch_queue(control_url):
         req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
         f = urllib2.urlopen(req)
         signal.alarm(0)
-    except Exception, e:
+    except Exception as e:
         signal.alarm(0)
         log.error("can't fetch %s: %s" % (control_url + "/queue.gz", e))
         sys.exit(1)
@@ -80,7 +80,7 @@ def fetch_queue(control_url):
     f = gzip.GzipFile(fileobj = sio)
     try:
         fdata = f.read()
-    except struct.error, e:
+    except struct.error as e:
         log.alert("corrupted fetched queue.gz file")
         sys.exit(1)
     (signers, body) = gpg.verify_sig(fdata)
@@ -102,7 +102,7 @@ def handle_reqs(builder, reqs):
     q.read()
     for r in reqs:
         if r.kind != 'group':
-            raise Exception, 'handle_reqs: fatal: huh? %s' % r.kind
+            raise Exception('handle_reqs: fatal: huh? %s' % r.kind)
         need_it = 0
         for b in r.batches:
             if builder in b.builders:
diff --git a/PLD_Builder/request_handler_server.py b/PLD_Builder/request_handler_server.py
index d944676..1ae3a3f 100644
--- a/PLD_Builder/request_handler_server.py
+++ b/PLD_Builder/request_handler_server.py
@@ -44,7 +44,7 @@ class MyHandler(BaseHTTPRequestHandler):
             self.send_response(200)
             self.end_headers()
 
-        except Exception, e:
+        except Exception as e:
             self.send_error(500, "%s: %s" % (filename, e))
             self.end_headers()
             log.error("request_handler_server: [%s]: exception: %s\n%s" % (self.client_address[0], e, traceback.format_exc()))
@@ -100,7 +100,7 @@ def main(srv_ssl=False):
                                 certfile = config.request_handler_server_ssl_cert,
                                 ca_certs = "/etc/certs/ca-certificates.crt",
                                 server_side=True)
-        except Exception, e:
+        except Exception as e:
             log.notice("request_handler_server: can't start server on [%s:%d], ssl=%s: %s" % (host, port, str(srv_ssl), e))
             print >> sys.stderr, "ERROR: Can't start server on [%s:%d], ssl=%s: %s" % (host, port, str(srv_ssl), e)
             sys.exit(1)
diff --git a/PLD_Builder/rpm_builder.py b/PLD_Builder/rpm_builder.py
index 08f63e2..a202f62 100644
--- a/PLD_Builder/rpm_builder.py
+++ b/PLD_Builder/rpm_builder.py
@@ -45,7 +45,7 @@ socket.socket=mysocket
 def pick_request(q):
     def mycmp(r1, r2):
         if r1.kind != 'group' or r2.kind != 'group':
-            raise Exception, "non-group requests"
+            raise Exception("non-group requests")
         pri_diff = cmp(r1.priority, r2.priority)
         if pri_diff == 0:
             return cmp(r1.time, r2.time)
@@ -65,9 +65,9 @@ def check_skip_build(r, b):
             req = urllib2.Request(url=src_url, headers=headers)
             f = urllib2.urlopen(req)
             good = True
-        except urllib2.HTTPError, error:
+        except urllib2.HTTPError as error:
             return False
-        except urllib2.URLError, error:
+        except urllib2.URLError as error:
             # see errno.h
             try:
                 errno = error.errno
@@ -95,19 +95,19 @@ def fetch_src(r, b):
             req = urllib2.Request(url=src_url, headers=headers)
             f = urllib2.urlopen(req)
             good = True
-        except urllib2.HTTPError, error:
+        except urllib2.HTTPError as error:
             # fail in a way where cron job will retry
             msg = "unable to fetch url %s, http code: %d" % (src_url, error.code)
             b.log_line(msg)
             queue_time = time.time() - r.time
             # 6 hours
             if error.code != 404 or (queue_time >= 0 and queue_time < (6 * 60 * 60)):
-                raise IOError, msg
+                raise IOError(msg)
             else:
                 msg = "in queue for more than 6 hours, download failing"
                 b.log_line(msg)
                 return False
-        except urllib2.URLError, error:
+        except urllib2.URLError as error:
             errno = 0
             if isinstance(error.args[0], IOError):
                 errno = error.args[0].errno
@@ -118,11 +118,11 @@ def fetch_src(r, b):
             else:
                 try:
                     print("error.errno: %s" % str(error.errno))
-                except Exception, e:
+                except Exception as e:
                     print("error.errno: exception %s" % e)
                 try:
                     print("error.reason %s" % str(error.reason))
-                except Exception, e:
+                except Exception as e:
                     print("error.reason exception %s" % e)
                 raise
 
@@ -130,7 +130,7 @@ def fetch_src(r, b):
 
     try:
         bytes = util.sendfile(f, o)
-    except IOError, e:
+    except IOError as e:
         b.log_line("error: unable to write to `%s': %s" % (b.src_rpm, e))
         raise
 
@@ -418,7 +418,7 @@ def main_for(builder):
 
 def main():
     if len(sys.argv) < 2:
-        raise Exception, "fatal: need to have builder name as first arg"
+        raise Exception("fatal: need to have builder name as first arg")
     return main_for(sys.argv[1])
 
 if __name__ == '__main__':
diff --git a/client/make-request.sh b/client/make-request.sh
index ed17f2d..605d949 100755
--- a/client/make-request.sh
+++ b/client/make-request.sh
@@ -111,7 +111,7 @@ try:
         req = urllib2.Request(url, data)
         f = urllib2.urlopen(req)
         f.close()
-except Exception, e:
+except Exception as e:
         print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e)
         sys.exit(1)
 print >> sys.stdout, "Request queued via HTTP."
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/5131e72930f3986dd82a660d6ba87b25920a7192



More information about the pld-cvs-commit mailing list