X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ticket.py;h=1904b81cc109361355cf788ea57c86ed02810a1c;hb=48a73b18fd7daed13c645c1adeddb57b560e7a2d;hp=0292cfb12bae0f237a248feb8f10147c61f166c0;hpb=3224c1906c82596a86ae734181488ed14a0f0976;p=nodemanager.git diff --git a/ticket.py b/ticket.py index 0292cfb..1904b81 100644 --- a/ticket.py +++ b/ticket.py @@ -1,6 +1,3 @@ -# $Id$ -# $URL$ - """An extremely simple interface to the signing/verifying capabilities of gnupg. @@ -8,10 +5,14 @@ You must already have the key in the keyring. """ from subprocess import PIPE, Popen -from xmlrpclib import dumps, loads +from xmlrpc.client import dumps, loads GPG = '/usr/bin/gpg' +def _popen_gpg(*args): + """Return a Popen object to GPG.""" + return Popen((GPG, '--batch', '--no-tty') + args, + stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) def sign(data): """Return signed with the default GPG key.""" @@ -33,11 +34,8 @@ def verify(signed_msg): msg = p.stdout.read() p.stdout.close() p.stderr.close() - if p.wait(): return None # verification failed + if p.wait(): + return None # verification failed else: data, = loads(msg)[0] return data - -def _popen_gpg(*args): - """Return a Popen object to GPG.""" - return Popen((GPG, '--batch', '--no-tty') + args, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)