diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-11-17 17:45:43 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-11-17 17:45:43 +0000 |
commit | edd18a77973d8cd12b09bc6e3ac06fecd72a7e45 (patch) | |
tree | 802046a1b53941cb15e325dd9685745aed4a0163 | |
parent | 86487edbf05f712bf6b351ae639cd10bcf87ba63 (diff) | |
parent | 80c60bf65cf0dda67e959d4d2ffc51e1c6cb94f8 (diff) | |
download | import-edd18a77973d8cd12b09bc6e3ac06fecd72a7e45.tar.gz |
Merge branch 'sam/post-review-changes'
Thanks to Richard Maw for finding most of these issues.
-rw-r--r-- | baserockimport/app.py | 6 | ||||
-rwxr-xr-x | baserockimport/exts/omnibus.to_chunk | 4 | ||||
-rw-r--r-- | baserockimport/mainloop.py | 12 |
3 files changed, 8 insertions, 14 deletions
diff --git a/baserockimport/app.py b/baserockimport/app.py index c7f0e05..6ae3424 100644 --- a/baserockimport/app.py +++ b/baserockimport/app.py @@ -131,10 +131,8 @@ class BaserockImportApplication(cliapp.Application): # directory. That messes up any relative paths the user may have # passed on the commandline, so we do a bit of a hack to change # back to the original directory inside the `bundle exec` process. - subshell_command = "(cd %s; exec python %s)" % \ - (pipes.quote(directory), ' '.join(map(pipes.quote, args))) - shell_command = "sh -c %s" % pipes.quote(subshell_command) - return shell_command + return "cd %s; exec python %s" % ( + pipes.quote(directory), ' '.join(map(pipes.quote, args))) def reexecute_self_with_bundler(path): script = sys.argv[0] diff --git a/baserockimport/exts/omnibus.to_chunk b/baserockimport/exts/omnibus.to_chunk index 5e527a9..0c56ea2 100755 --- a/baserockimport/exts/omnibus.to_chunk +++ b/baserockimport/exts/omnibus.to_chunk @@ -51,8 +51,8 @@ class OmnibusChunkMorphologyGenerator < Importer::Base end def run_tool_capture_output(tool_name, *args) - scripts_dir = local_data_path('.') - tool_path = local_data_path(tool_name) + scripts_dir = File.dirname(__FILE__) + tool_path = File.join(scripts_dir, tool_name) # FIXME: something breaks when we try to share this FD, it's not # ideal that the subprocess doesn't log anything, though. diff --git a/baserockimport/mainloop.py b/baserockimport/mainloop.py index 345e45e..99fb8d2 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 @@ -574,7 +571,6 @@ class ImportLoop(object): 'chunks': chunk_entries, } - morphology = self.morphloader.load_from_string( - json.dumps(stratum), filename=filename) - self.morphloader.unset_defaults(morphology) + morphology = self.morphology.Morphology(stratum) + morphology.filename = filename self.morphloader.save_to_file(filename, morphology) |