[windows] fix probleme using NamedTemporaryFile on windows
This commit is contained in:
parent
8972743bd7
commit
c3b5dbc316
1 changed files with 24 additions and 15 deletions
|
|
@ -777,7 +777,12 @@ class Keyring(object):
|
||||||
"""
|
"""
|
||||||
gpgv = self.find_gpgv()
|
gpgv = self.find_gpgv()
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
with NamedTemporaryFile(suffix='.sig') as sigfile:
|
with NamedTemporaryFile(suffix='.sig', delete=False) as sigfile:
|
||||||
|
temp_filename = sigfile.name
|
||||||
|
return_code = None
|
||||||
|
out = ''
|
||||||
|
err = ''
|
||||||
|
try:
|
||||||
sigfile.write(sigdata)
|
sigfile.write(sigdata)
|
||||||
sigfile.flush() # very important
|
sigfile.flush() # very important
|
||||||
assert isinstance(data, basestring)
|
assert isinstance(data, basestring)
|
||||||
|
|
@ -791,7 +796,11 @@ class Keyring(object):
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
out, err = proc.communicate(data)
|
out, err = proc.communicate(data)
|
||||||
if proc.returncode or 'GOODSIG' not in out or 'VALIDSIG' not in out:
|
return_code = proc.returncode
|
||||||
|
finally:
|
||||||
|
os.unlink(temp_filename)
|
||||||
|
|
||||||
|
if return_code or 'GOODSIG' not in out or 'VALIDSIG' not in out:
|
||||||
print(out, err, file=sys.stderr)
|
print(out, err, file=sys.stderr)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue