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):
gid = stat_info.st_gid
# Get the list of promises
promise_dir = os.join(instance_path, 'etc', 'promise')
commands_to_run = os.listdir(promise_dir)
cwd = instance_path
# Check whether every promise is kept
for process_handler, command in \
self._runCommandAsUserAndYieldPopen(commands_to_run,
(uid, gid), cwd):
time.sleep(self.promise_timeout)
promise = os.path.basename(command)
if process_handler.poll() is None:
process_handler.kill()
computer_partition.error("The promise %r timed out" % promise)
elif process_handler.returncode != 0:
stderr = process_handler.communicate()[1]
if stderr is None:
stderr = 'No error output from %r.' % promise
computer_partition.error(stderr)
promise_dir = os.path.join(instance_path, 'etc', 'promise')
if os.path.exists(promise_dir) and os.path.isdir(promise_dir):
commands_to_run = os.listdir(promise_dir)
cwd = instance_path
# Check whether every promise is kept
for process_handler, command in \
self._runCommandAsUserAndYieldPopen(commands_to_run,
(uid, gid), cwd):
time.sleep(self.promise_timeout)
promise = os.path.basename(command)
if process_handler.poll() is None:
process_handler.kill()
computer_partition.error("The promise %r timed out" % promise)
elif process_handler.returncode != 0:
stderr = process_handler.communicate()[1]
if stderr is None:
stderr = 'No error output from %r.' % promise
computer_partition.error(stderr)
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