mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Make extdev more robust against crashes of test command
This commit is contained in:
parent
7f1519989f
commit
ac29ca24a7
@ -188,12 +188,16 @@ class ExtDev(Command):
|
|||||||
if not isinstance(enc, bytes):
|
if not isinstance(enc, bytes):
|
||||||
enc = enc.encode('utf-8')
|
enc = enc.encode('utf-8')
|
||||||
enc = binascii.hexlify(enc).decode('ascii')
|
enc = binascii.hexlify(enc).decode('ascii')
|
||||||
cmd = ['"{}"'.format(os.path.join(bin_dir, 'calibre-debug')), '-c', '"'
|
wcmd = ['"{}"'.format(os.path.join(bin_dir, 'calibre-debug')), '-c', '"'
|
||||||
'import sys, json, binascii, os; cmd = json.loads(binascii.unhexlify(sys.argv[-1]));'
|
'import sys, json, binascii, os, subprocess; cmd = json.loads(binascii.unhexlify(sys.argv[-1]));'
|
||||||
'''os.environ['CALIBRE_DEVELOP_FROM'] = os.path.expanduser('~/calibre-src/src');'''
|
'env = os.environ.copy();'
|
||||||
|
'''env[str('CALIBRE_DEVELOP_FROM')] = str(os.path.abspath('calibre-src/src'));'''
|
||||||
'from calibre.debug import get_debug_executable; exe_dir = os.path.dirname(get_debug_executable());'
|
'from calibre.debug import get_debug_executable; exe_dir = os.path.dirname(get_debug_executable());'
|
||||||
'os.execv(os.path.join(exe_dir, cmd[0]), cmd)'
|
'cmd[0] = os.path.join(exe_dir, cmd[0]); ret = subprocess.Popen(cmd, env=env).wait();'
|
||||||
|
'sys.stdout.flush(); sys.stderr.flush(); sys.exit(ret)'
|
||||||
'"', enc]
|
'"', enc]
|
||||||
subprocess.check_call(['ssh', '-S', control_path, host] + cmd)
|
ret = subprocess.Popen(['ssh', '-S', control_path, host] + wcmd).wait()
|
||||||
|
if ret != 0:
|
||||||
|
raise SystemExit('The test command "{}" failed with exit code: {}'.format(' '.join(cmd), ret))
|
||||||
finally:
|
finally:
|
||||||
subprocess.Popen(['ssh', '-O', 'exit', '-S', control_path, host])
|
subprocess.Popen(['ssh', '-O', 'exit', '-S', control_path, host])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user