Commit 7a464acc authored by Xavier Thompson's avatar Xavier Thompson

software/theia: Capture errors in import script

parent 9c59c5fc
...@@ -43,7 +43,7 @@ md5sum = e2f6c483cce09f87ab1e63ae8be0daf4 ...@@ -43,7 +43,7 @@ md5sum = e2f6c483cce09f87ab1e63ae8be0daf4
[theia-import] [theia-import]
_update_hash_filename_ = theia_import.py _update_hash_filename_ = theia_import.py
md5sum = 5dea99b0106cccba65f8ae90d110e111 md5sum = 1a668d6203d42b4d46d56e24c7606cb2
[yarn.lock] [yarn.lock]
_update_hash_filename_ = yarn.lock _update_hash_filename_ = yarn.lock
......
...@@ -90,12 +90,12 @@ class TheiaImport(object): ...@@ -90,12 +90,12 @@ class TheiaImport(object):
supervisor_command = (self.supervisorctl_bin, '-c', self.supervisord_conf) supervisor_command = (self.supervisorctl_bin, '-c', self.supervisord_conf)
command = supervisor_command + args command = supervisor_command + args
print(' '.join(command)) print(' '.join(command))
sp.check_call(command) print(sp.check_output(command, stderr=sp.STDOUT, universal_newlines=True))
def slapos(self, *args): def slapos(self, *args):
command = (self.slapos_bin,) + args + ('--cfg', self.slapos_cfg) command = (self.slapos_bin,) + args + ('--cfg', self.slapos_cfg)
print(' '.join(command)) print(' '.join(command))
sp.check_call(command) print(sp.check_output(command, stderr=sp.STDOUT, universal_newlines=True))
def sign(self, signaturefile, root_dir): def sign(self, signaturefile, root_dir):
with open(signaturefile, 'r') as f: with open(signaturefile, 'r') as f:
...@@ -159,9 +159,11 @@ class TheiaImport(object): ...@@ -159,9 +159,11 @@ class TheiaImport(object):
exitcode = 0 exitcode = 0
try: try:
self.restore() self.restore()
except Exception: except Exception as e:
exitcode = 1 exitcode = 1
exc = traceback.format_exc() exc = traceback.format_exc()
if isinstance(e, sp.CalledProcessError) and e.output:
exc = "%s\n\n%s" % (exc, e.output)
with open(self.error_file, 'w') as f: with open(self.error_file, 'w') as f:
f.write('\n ... OK\n\n'.join(self.logs)) f.write('\n ... OK\n\n'.join(self.logs))
f.write('\n ... ERROR !\n\n') f.write('\n ... ERROR !\n\n')
...@@ -207,7 +209,7 @@ class TheiaImport(object): ...@@ -207,7 +209,7 @@ class TheiaImport(object):
custom_script = os.path.join(self.root_dir, 'srv', 'runner-import-restore') custom_script = os.path.join(self.root_dir, 'srv', 'runner-import-restore')
if os.path.exists(custom_script): if os.path.exists(custom_script):
self.log('Run custom restore script %s' % custom_script) self.log('Run custom restore script %s' % custom_script)
sp.check_call(custom_script) print(sp.check_output(custom_script))
self.log('Start slapproxy again') self.log('Start slapproxy again')
self.supervisorctl('start', 'slapos-proxy') self.supervisorctl('start', 'slapos-proxy')
...@@ -258,7 +260,7 @@ class TheiaImport(object): ...@@ -258,7 +260,7 @@ class TheiaImport(object):
for custom_script in glob.glob(scripts): for custom_script in glob.glob(scripts):
self.log('Running custom instance script %s' % custom_script) self.log('Running custom instance script %s' % custom_script)
sp.check_call(custom_script) print(sp.check_output(custom_script))
self.log('Done') self.log('Done')
......
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