make code execution happen in the end

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-09-11 20:41:39 +02:00
parent 4e4d648593
commit 34ae8c2926

View file

@ -516,6 +516,12 @@ class Cdist:
self.shell_run_or_debug_fail(bin, [bin], env=env, stdout=outfile_fd) self.shell_run_or_debug_fail(bin, [bin], env=env, stdout=outfile_fd)
outfile_fd.close() outfile_fd.close()
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) os.chmod(outfile, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR)
if mode == "code": if mode == "code":
@ -527,9 +533,12 @@ class Cdist:
if os.path.isfile(bin): if os.path.isfile(bin):
self.run_or_fail([bin], remote=False) 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") local_remote_code = os.path.join(local_dir, "code-remote")
self.run_or_fail([remote_code], remote=True) 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): def deploy_to(self):
"""Mimic the old deploy to: Deploy to one host""" """Mimic the old deploy to: Deploy to one host"""