Fix path creation.

hotfix/pin-psutil-version
drebs 2013-10-14 17:09:09 -03:00
parent e6944488fb
commit 678d36ea62
2 changed files with 7 additions and 6 deletions

View File

@ -557,18 +557,20 @@ class GPG(GPGBase):
fpr = str(key.fingerprint)
if len(fpr) == 20:
if self.temp_keyring or self.temp_secring:
if not os.path.exists(self._keys_dir):
os.makedirs(self._keys_dir)
prefix = os.path.join(self._keys_dir, fpr)
for d in map(lambda x: os.path.dirname(x),
[self.temp_keyring, self.temp_secring]):
if not os.path.exists(d):
os.makedirs(d)
if self.temp_keyring:
if os.path.isfile(self.temp_keyring):
prefix = os.path.join(self.temp_keyring, fpr)
try: os.rename(self.temp_keyring, prefix+".pubring")
except OSError as ose: log.error(ose.message)
if self.temp_secring:
if os.path.isfile(self.temp_secring):
prefix = os.path.join(self.temp_secring, fpr)
try: os.rename(self.temp_secring, prefix+".secring")
except OSError as ose: log.error(ose.message)

View File

@ -173,7 +173,6 @@ class GPGTestCase(unittest.TestCase):
self.keyring = self.gpg.keyring
self.secring = self.gpg.secring
self.insecure_prng = False
self.gpg._keys_dir = os.path.join(_files, 'generated-keys')
def tearDown(self):
"""This is called once per self.test_* method after the test run."""
@ -523,7 +522,7 @@ class GPGTestCase(unittest.TestCase):
self.assertIsNotNone(key)
self.assertNotEquals(key, "")
self.assertGreater(len(str(key)), 0)
keyfile = os.path.join(self.gpg._keys_dir, 'test_key_3.pub')
keyfile = os.path.join(_files, 'test_key_3.pub')
log.debug("Storing downloaded key as %s" % keyfile)
with open(keyfile, 'w') as fh:
fh.write(str(key))