10 from contextlib
import contextmanager, nested
16 """ Wait for a subprocess.Popen object to terminate, or until timeout (in seconds) expires. """
22 p = subprocess.Popen(cmd, *args, **kwargs)
27 t = threading.Thread(target=
lambda: p.communicate())
34 if p
is not None and p.poll()
is None:
37 if t
is not None and t.is_alive():
47 file = tempfile.NamedTemporaryFile(delete=
False, suffix=suffix)
57 if sys.platform ==
"win32":
58 if os.path.isabs(path):
59 drive, tail = os.path.splitdrive(path)
61 tail = tail.split(os.path.sep)
62 return '/cygdrive/%s'%drive[0] +
'/'.join(tail)
64 path = path.split(os.path.sep)
70 pyabc.run_command(
"write %s"%tmpaig_name)
74 'qua_ffix -effort %d -L %s'%(effort,
cygpath(tmplog_name)),
78 cmd = [
"jabc",
"-c",
" ; ".join(cmdline)]
84 with open(tmplog_name,
"w")
as f:
85 f.write(
'snl_UNK -1 unknown\n')
89 pyabc.run_command(
"read_status %s"%tmplog_name)
94 usage =
"usage: %prog [options]"
96 parser = optparse.OptionParser(usage, prog=
"reachx")
98 parser.add_option(
"-e",
"--effort", dest=
"effort", type=int, default=0, help=
"effort level. [default=0, means unlimited]")
99 parser.add_option(
"-t",
"--timeout", dest=
"timeout", type=int, default=0, help=
"timeout in seconds [default=0, unlimited]")
101 options, args = parser.parse_args(argv)
104 print "%s command: jabc returned: %d"%(argv[0], rc)
108 pyabc.add_abc_command(reachx_cmd,
"Verification",
"reachx", 0)
def popen_and_wait_with_timeout