From 34ae8c292689780db3c18047bcd9d9493cf4f9be Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 11 Sep 2011 20:41:39 +0200 Subject: [PATCH] make code execution happen in the end Signed-off-by: Nico Schottelius --- bin/cdist | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/cdist b/bin/cdist index 09cb9d45..1fd3e116 100755 --- a/bin/cdist +++ b/bin/cdist @@ -516,7 +516,13 @@ class Cdist: self.shell_run_or_debug_fail(bin, [bin], env=env, stdout=outfile_fd) outfile_fd.close() - os.chmod(outfile, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR) + status = os.stat(outfile) + + # Remove output if empty, else make it executable + if status.st_size == 0: + os.unlink(outfile) + else: + os.chmod(outfile, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR) if mode == "code": # paths = self.object_code_paths(cdist_object) @@ -527,9 +533,12 @@ class Cdist: if os.path.isfile(bin): self.run_or_fail([bin], remote=False) - if os.path.isfile(os.path.join(local_dir, "code-remote")): - remote_code = os.path.join(remote_dir, "code-remote") - self.run_or_fail([remote_code], remote=True) + + local_remote_code = os.path.join(local_dir, "code-remote") + remote_remote_code = os.path.join(remote_dir, "code-remote") + if os.path.isfile(local_remote_code): + self.transfer_file(local_remote_code, remote_remote_code) + self.run_or_fail([remote_remote_code], remote=True) def deploy_to(self): """Mimic the old deploy to: Deploy to one host"""