]> TLD Linux GIT Repositories - tld-builder.git/blobdiff - TLD_Builder/gpg.py
- merged PLD changes, now it works with python 3.x
[tld-builder.git] / TLD_Builder / gpg.py
index aeb8ebd4e524a3cf1da1fe35002a17544a792d02..055c39083d286eb95263b4c7c271bcb5b8753809 100644 (file)
@@ -3,7 +3,11 @@
 import log
 import subprocess
 import re
-import StringIO
+import sys
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 
 import util
 import os
@@ -24,11 +28,11 @@ 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
 
-    rx = re.compile("^gpg: Signature made .*using [DR]SA key ID (.+)")
+    rx = re.compile("^gpg:.*using\s[DR]SA\skey\s(?:ID\s)?(\w+)")
     keys = []
 
     for l in d_stderr.split('\n'):
@@ -56,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
 
@@ -82,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