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