pld-builder.new: PLD_Builder/bqueue.py, PLD_Builder/gpg.py, PLD_Builder/not...
arekm
arekm at pld-linux.org
Fri Feb 6 11:35:57 CET 2009
Author: arekm Date: Fri Feb 6 10:35:57 2009 GMT
Module: pld-builder.new Tag: HEAD
---- Log message:
Switch to subprocess module for gpg. Use strings instead of I/O objects for passing gpg data.
---- Files affected:
pld-builder.new/PLD_Builder:
bqueue.py (1.9 -> 1.10) , gpg.py (1.19 -> 1.20) , notify.py (1.5 -> 1.6) , request.py (1.50 -> 1.51) , request_fetcher.py (1.23 -> 1.24)
---- Diffs:
================================================================
Index: pld-builder.new/PLD_Builder/bqueue.py
diff -u pld-builder.new/PLD_Builder/bqueue.py:1.9 pld-builder.new/PLD_Builder/bqueue.py:1.10
--- pld-builder.new/PLD_Builder/bqueue.py:1.9 Thu Dec 9 19:09:03 2004
+++ pld-builder.new/PLD_Builder/bqueue.py Fri Feb 6 11:35:52 2009
@@ -54,12 +54,12 @@
def read(self):
self._open()
self.signers = []
- if string.strip(self.fd.read()) == "":
+ body = self.fd.read()
+ if string.strip(body) == "":
# empty file, don't choke
self.requests = []
return
- self.fd.seek(0)
- self.requests = request.parse_requests(self.fd)
+ self.requests = request.parse_requests(body)
def _write_to(self, f):
f.write("<queue>\n")
================================================================
Index: pld-builder.new/PLD_Builder/gpg.py
diff -u pld-builder.new/PLD_Builder/gpg.py:1.19 pld-builder.new/PLD_Builder/gpg.py:1.20
--- pld-builder.new/PLD_Builder/gpg.py:1.19 Thu Jul 17 12:02:49 2008
+++ pld-builder.new/PLD_Builder/gpg.py Fri Feb 6 11:35:52 2009
@@ -1,7 +1,7 @@
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
import log
-import popen2
+import subprocess
import re
import StringIO
@@ -9,11 +9,6 @@
import os
import pipeutil
-def __gpg_close(descriptors):
- for d in descriptors:
- if not d.closed:
- d.close()
-
def get_keys(buf):
"""Extract keys from gpg message
@@ -23,18 +18,20 @@
log.error("missing gnupg binary: /usr/bin/gpg")
raise OSError, 'Missing gnupg binary'
- gpg_run = popen2.Popen3("/usr/bin/gpg --batch --no-tty --decrypt", True)
+ d_stdout = None
+ d_stderr = None
+ cmd = ['/usr/bin/gpg', '--batch', '--no-tty', '--decrypt']
+ gpg_run = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
try:
- body = pipeutil.rw_pipe(buf, gpg_run.tochild, gpg_run.fromchild)
+ d_stdout, d_stderr = gpg_run.communicate(buf.read())
except OSError, e:
- __gpg_close([gpg_run.fromchild, gpg_run.childerr, gpg_run.tochild])
- gpg_run.wait()
log.error("gnupg run, does gpg binary exist? : %s" % e)
raise
rx = re.compile("^gpg: Signature made .*using [DR]SA key ID (.+)")
keys = []
- for l in gpg_run.childerr.xreadlines():
+
+ for l in d_stderr.xreadlines():
m = rx.match(l)
if m:
keys.append(m.group(1))
@@ -53,39 +50,37 @@
log.error("missing gnupg binary: /usr/bin/gpg")
raise OSError, 'Missing gnupg binary'
- gpg_run = popen2.Popen3("/usr/bin/gpg --batch --no-tty --decrypt", True)
+ d_stdout = None
+ d_stderr = None
+ cmd = ['/usr/bin/gpg', '--batch', '--no-tty', '--decrypt']
+ gpg_run = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
try:
- body = pipeutil.rw_pipe(buf, gpg_run.tochild, gpg_run.fromchild)
+ d_stdout, d_stderr = gpg_run.communicate(buf.read())
except OSError, e:
- __gpg_close([gpg_run.fromchild, gpg_run.childerr, gpg_run.tochild])
- gpg_run.wait()
log.error("gnupg run failed, does gpg binary exist? : %s" % e)
raise
rx = re.compile("^gpg: (Good signature from| aka) .*<([^>]+)>")
emails = []
- for l in gpg_run.childerr.xreadlines():
+ for l in d_stderr.split('\n'):
m = rx.match(l)
if m:
emails.append(m.group(2))
- __gpg_close([gpg_run.fromchild, gpg_run.childerr, gpg_run.tochild])
- gpg_run.wait()
- return (emails, body)
+ return (emails, d_stdout)
def sign(buf):
if not os.path.isfile('/usr/bin/gpg'):
log.error("missing gnupg binary: /usr/bin/gpg")
raise OSError, 'Missing gnupg binary'
- gpg_run = popen2.Popen3("/usr/bin/gpg --batch --no-tty --clearsign", True)
+ d_stdout = None
+ d_stderr = None
+ cmd = ['/usr/bin/gpg', '--batch', '--no-tty', '--clearsign']
+ gpg_run = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
try:
- body = pipeutil.rw_pipe(buf, gpg_run.tochild, gpg_run.fromchild)
+ d_stdout, d_stderr = gpg_run.communicate(buf.read())
except OSError, e:
- __gpg_close([gpg_out, gpg_err, gpg_in])
- gpg_run.wait()
log.error("gnupg signing failed, does gpg binary exist? : %s" % e)
raise
- __gpg_close([gpg_run.fromchild, gpg_run.childerr, gpg_run.tochild])
- gpg_run.wait()
- return body
+ return d_stdout
================================================================
Index: pld-builder.new/PLD_Builder/notify.py
diff -u pld-builder.new/PLD_Builder/notify.py:1.5 pld-builder.new/PLD_Builder/notify.py:1.6
--- pld-builder.new/PLD_Builder/notify.py:1.5 Wed Mar 7 20:18:32 2007
+++ pld-builder.new/PLD_Builder/notify.py Fri Feb 6 11:35:52 2009
@@ -18,7 +18,7 @@
sio = StringIO.StringIO()
self.xml.write("</notification>\n")
self.xml.seek(0)
- util.sendfile(gpg.sign(self.xml), sio)
+ sio.write(gpg.sign(self.xml))
self.xml = None
sio.seek(0)
notifyq.init(r)
================================================================
Index: pld-builder.new/PLD_Builder/request.py
diff -u pld-builder.new/PLD_Builder/request.py:1.50 pld-builder.new/PLD_Builder/request.py:1.51
--- pld-builder.new/PLD_Builder/request.py:1.50 Tue Jan 20 09:54:31 2009
+++ pld-builder.new/PLD_Builder/request.py Fri Feb 6 11:35:52 2009
@@ -333,11 +333,11 @@
log.panic("xml: evil request <%s>" % e.nodeName)
def parse_request(f):
- d = parse(f)
+ d = parseString(f)
return build_request(d.documentElement)
def parse_requests(f):
- d = parse(f)
+ d = parseString(f)
res = []
for r in d.documentElement.childNodes:
if is_blank(r): continue
================================================================
Index: pld-builder.new/PLD_Builder/request_fetcher.py
diff -u pld-builder.new/PLD_Builder/request_fetcher.py:1.23 pld-builder.new/PLD_Builder/request_fetcher.py:1.24
--- pld-builder.new/PLD_Builder/request_fetcher.py:1.23 Fri Jul 18 13:46:13 2008
+++ pld-builder.new/PLD_Builder/request_fetcher.py Fri Feb 6 11:35:52 2009
@@ -77,7 +77,6 @@
if not u.can_do("sign_queue", "all"):
log.alert("user %s is not allowed to sign my queue" % u.login)
sys.exit(1)
- body.seek(0)
return request.parse_requests(body)
def handle_reqs(builder, reqs):
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-builder.new/PLD_Builder/bqueue.py?r1=1.9&r2=1.10&f=u
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-builder.new/PLD_Builder/gpg.py?r1=1.19&r2=1.20&f=u
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-builder.new/PLD_Builder/notify.py?r1=1.5&r2=1.6&f=u
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-builder.new/PLD_Builder/request.py?r1=1.50&r2=1.51&f=u
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-builder.new/PLD_Builder/request_fetcher.py?r1=1.23&r2=1.24&f=u
More information about the pld-cvs-commit
mailing list