Commit 9af4f13a authored by Antoine Catton's avatar Antoine Catton

Minor: check if promise dir exists before list it

This solve the problem of software release which doesn't provide
any promise
parent 671d052c
...@@ -475,27 +475,28 @@ class Slapgrid(object): ...@@ -475,27 +475,28 @@ class Slapgrid(object):
gid = stat_info.st_gid gid = stat_info.st_gid
# Get the list of promises # Get the list of promises
promise_dir = os.join(instance_path, 'etc', 'promise') promise_dir = os.path.join(instance_path, 'etc', 'promise')
commands_to_run = os.listdir(promise_dir) if os.path.exists(promise_dir) and os.path.isdir(promise_dir):
cwd = instance_path commands_to_run = os.listdir(promise_dir)
cwd = instance_path
# Check whether every promise is kept
for process_handler, command in \ # Check whether every promise is kept
self._runCommandAsUserAndYieldPopen(commands_to_run, for process_handler, command in \
(uid, gid), cwd): self._runCommandAsUserAndYieldPopen(commands_to_run,
(uid, gid), cwd):
time.sleep(self.promise_timeout)
time.sleep(self.promise_timeout)
promise = os.path.basename(command)
promise = os.path.basename(command)
if process_handler.poll() is None:
process_handler.kill() if process_handler.poll() is None:
computer_partition.error("The promise %r timed out" % promise) process_handler.kill()
elif process_handler.returncode != 0: computer_partition.error("The promise %r timed out" % promise)
stderr = process_handler.communicate()[1] elif process_handler.returncode != 0:
if stderr is None: stderr = process_handler.communicate()[1]
stderr = 'No error output from %r.' % promise if stderr is None:
computer_partition.error(stderr) stderr = 'No error output from %r.' % promise
computer_partition.error(stderr)
logger.info("Finished computer partitions...") logger.info("Finished computer partitions...")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment