aboutsummaryrefslogtreecommitdiffstats
path: root/minidinstall/GPGSigVerifier.py
diff options
context:
space:
mode:
authorLibravatarKrytarik Raido <krytarik@tuxgarage.com>2018-04-03 06:50:04 +0200
committerLibravatarKrytarik Raido <krytarik@tuxgarage.com>2018-04-03 06:50:04 +0200
commitdc580be8f9ef38a1c0903820b04e1b5c7217da16 (patch)
tree4a214d88d3e094efdb9e4ff70920537a4d33ae9b /minidinstall/GPGSigVerifier.py
parent23ac25c0b388b5ffebf66154b12a3950b89b977a (diff)
Various improvements in coding style.
Diffstat (limited to 'minidinstall/GPGSigVerifier.py')
-rw-r--r--minidinstall/GPGSigVerifier.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/minidinstall/GPGSigVerifier.py b/minidinstall/GPGSigVerifier.py
index 2e0dee5..0d47379 100644
--- a/minidinstall/GPGSigVerifier.py
+++ b/minidinstall/GPGSigVerifier.py
@@ -2,7 +2,7 @@
# A class for verifying signed files
-# Copyright © 2002 Colin Walters <walters@gnu.org>
+# Copyright (c) 2002 Colin Walters <walters@gnu.org>
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -18,8 +18,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-import os, re, sys, string, stat
-from minidinstall import misc
+import os
+from . import misc
class GPGSigVerifierException(Exception):
def __init__(self, value):
@@ -40,10 +40,10 @@ class GPGSigVerificationFailure(Exception):
class GPGSigVerifier:
def __init__(self, keyrings, gpgv=None):
self._keyrings = keyrings
- if gpgv is None:
+ if not gpgv:
gpgv = '/usr/bin/gpgv'
if not os.access(gpgv, os.X_OK):
- raise GPGSigVerifierException("Couldn't execute \"%s\"" % (gpgv,))
+ raise GPGSigVerifierException("Couldn't execute \"%s\"" % gpgv)
self._gpgv = gpgv
def verify(self, filename, sigfilename=None):
@@ -53,25 +53,24 @@ class GPGSigVerifier:
os.close(stdin)
misc.dup2(stdout, 1)
misc.dup2(stdout, 2)
- args = []
+ args = [self._gpgv]
for keyring in self._keyrings:
- args.append('--keyring')
- args.append(keyring)
+ args.extend(['--keyring', keyring])
if sigfilename:
args.append(sigfilename)
- args = [self._gpgv] + args + [filename]
+ args.append(filename)
os.execv(self._gpgv, args)
os.exit(1)
os.close(stdout)
output = os.fdopen(stdin).readlines()
(pid, status) = os.waitpid(pid, 0)
- if not (status is None or (os.WIFEXITED(status) and os.WEXITSTATUS(status) == 0)):
+ if status or (not os.WIFEXITED(status) and os.WEXITSTATUS(status) != 0):
if os.WIFEXITED(status):
- msg = "gpgv exited with error code %d" % (os.WEXITSTATUS(status),)
+ msg = "gpgv exited with error code %d" % os.WEXITSTATUS(status)
elif os.WIFSTOPPED(status):
- msg = "gpgv stopped unexpectedly with signal %d" % (os.WSTOPSIG(status),)
+ msg = "gpgv stopped unexpectedly with signal %d" % os.WSTOPSIG(status)
elif os.WIFSIGNALED(status):
- msg = "gpgv died with signal %d" % (os.WTERMSIG(status),)
+ msg = "gpgv died with signal %d" % os.WTERMSIG(status)
raise GPGSigVerificationFailure(msg, output)
return output