Change the default parameter values in common.MakeTempFile().
tempfile.TemporaryFile() complains when 'None' is passed as the
prefix/suffix. It uses prefix='tmp' and suffix='' as the default values
and we should do the same.
Test: Call check_ota_package_signature.py and ota_from_target_files.py
and they still work.
Change-Id: I7fb023a3fd0b1a57c009631d0c57a7bb8e4cb5a3
diff --git a/tools/releasetools/check_ota_package_signature.py b/tools/releasetools/check_ota_package_signature.py
index 0da61b1..548b619 100755
--- a/tools/releasetools/check_ota_package_signature.py
+++ b/tools/releasetools/check_ota_package_signature.py
@@ -104,7 +104,7 @@
# Get the signature from the input package.
signature = package_bytes[signature_start:-6]
- sig_file = common.MakeTempFile(prefix='sig-', suffix='')
+ sig_file = common.MakeTempFile(prefix='sig-')
with open(sig_file, 'wb') as f:
f.write(signature)
@@ -116,12 +116,12 @@
digest_line = sig.strip().split('\n')[-1]
digest_string = digest_line.split(':')[3]
- digest_file = common.MakeTempFile(prefix='digest-', suffix='')
+ digest_file = common.MakeTempFile(prefix='digest-')
with open(digest_file, 'wb') as f:
f.write(digest_string.decode('hex'))
# Verify the digest by outputing the decrypted result in ASN.1 structure.
- decrypted_file = common.MakeTempFile(prefix='decrypted-', suffix='')
+ decrypted_file = common.MakeTempFile(prefix='decrypted-')
cmd = ['openssl', 'rsautl', '-verify', '-certin', '-inkey', cert,
'-in', digest_file, '-out', decrypted_file]
p1 = common.Run(cmd, stdout=subprocess.PIPE)
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 3f3b011..4f24ad5 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -990,7 +990,7 @@
return args
-def MakeTempFile(prefix=None, suffix=None):
+def MakeTempFile(prefix='tmp', suffix=''):
"""Make a temp file and add it to the list of things to be deleted
when Cleanup() is called. Return the filename."""
fd, fn = tempfile.mkstemp(prefix=prefix, suffix=suffix)