diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-11-17 17:14:48 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-11-17 17:14:48 +0000 |
commit | 57531aaa135ea6ad19430ff8d5398a378db4e7b4 (patch) | |
tree | d4706f4063e62bbd11eac20618faed46ef36ac7f /baserockimport/mainloop.py | |
parent | 86487edbf05f712bf6b351ae639cd10bcf87ba63 (diff) | |
download | import-57531aaa135ea6ad19430ff8d5398a378db4e7b4.tar.gz |
Clean up use of a temporary file slightly
Diffstat (limited to 'baserockimport/mainloop.py')
-rw-r--r-- | baserockimport/mainloop.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/baserockimport/mainloop.py b/baserockimport/mainloop.py index 345e45e..a84d547 100644 --- a/baserockimport/mainloop.py +++ b/baserockimport/mainloop.py @@ -327,17 +327,14 @@ class ImportLoop(object): return lorry def _run_lorry(self, lorry): - f = tempfile.NamedTemporaryFile(delete=False) - try: + with tempfile.NamedTemporaryFile() as f: logging.debug(json.dumps(lorry)) json.dump(lorry, f) - f.close() + f.flush() cliapp.runcmd([ 'lorry', '--working-area', self.app.settings['lorry-working-dir'], '--pull-only', '--bundle', 'never', '--tarball', 'never', f.name]) - finally: - os.unlink(f.name) def _fetch_or_update_source(self, lorry): assert len(lorry) == 1 |