abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
reachx_cmd Namespace Reference

Functions

def popen_and_wait_with_timeout
 
def temp_file_name
 
def cygpath
 
def run_reachx_cmd
 
def reachx_cmd
 

Function Documentation

def reachx_cmd.cygpath (   path)

Definition at line 56 of file reachx_cmd.py.

56 
57 def cygpath(path):
58  if sys.platform == "win32":
59  if os.path.isabs(path):
60  drive, tail = os.path.splitdrive(path)
61  drive = drive.lower()
62  tail = tail.split(os.path.sep)
63  return '/cygdrive/%s'%drive[0] + '/'.join(tail)
64  else:
65  path = path.split(os.path.sep)
66  return "/".join(path)
67  return path
def cygpath
Definition: reachx_cmd.py:56
def reachx_cmd.popen_and_wait_with_timeout (   timeout,
  cmd,
  args,
  kwargs 
)
Wait for a subprocess.Popen object to terminate, or until timeout (in seconds) expires. 

Definition at line 15 of file reachx_cmd.py.

15 
16 def popen_and_wait_with_timeout(timeout,cmd, *args, **kwargs):
17  """ Wait for a subprocess.Popen object to terminate, or until timeout (in seconds) expires. """
18 
19  p = None
20  t = None
21 
22  try:
23  p = subprocess.Popen(cmd, *args, **kwargs)
24 
25  if timeout <= 0:
26  timeout = None
27 
28  t = threading.Thread(target=lambda: p.communicate())
29  t.start()
30 
31  t.join(timeout)
32 
33  finally:
34 
35  if p is not None and p.poll() is None:
36  p.kill()
37 
38  if t is not None and t.is_alive():
39  t.join()
40 
41  if p is not None:
42  return p.returncode
43 
44  return -1
45 
@contextmanager
def popen_and_wait_with_timeout
Definition: reachx_cmd.py:15
def reachx_cmd.reachx_cmd (   argv)

Definition at line 93 of file reachx_cmd.py.

93 
94 def reachx_cmd(argv):
95  usage = "usage: %prog [options]"
96 
97  parser = optparse.OptionParser(usage, prog="reachx")
98 
99  parser.add_option("-e", "--effort", dest="effort", type=int, default=0, help="effort level. [default=0, means unlimited]")
100  parser.add_option("-t", "--timeout", dest="timeout", type=int, default=0, help="timeout in seconds [default=0, unlimited]")
101 
102  options, args = parser.parse_args(argv)
103 
104  rc = run_reachx_cmd(options.effort, options.timeout)
105  print "%s command: jabc returned: %d"%(argv[0], rc)
106 
107  return 0
108 
109 pyabc.add_abc_command(reachx_cmd, "Verification", "reachx", 0)
def reachx_cmd
Definition: reachx_cmd.py:93
def run_reachx_cmd
Definition: reachx_cmd.py:68
def reachx_cmd.run_reachx_cmd (   effort,
  timeout 
)

Definition at line 68 of file reachx_cmd.py.

68 
69 def run_reachx_cmd(effort, timeout):
70  with nested(temp_file_name(suffix=".aig"), temp_file_name()) as (tmpaig_name, tmplog_name):
71  pyabc.run_command("write %s"%tmpaig_name)
72 
73  cmdline = [
74  'read %s'%cygpath(tmpaig_name),
75  'qua_ffix -effort %d -L %s'%(effort, cygpath(tmplog_name)),
76  'quit'
77  ]
78 
79  cmd = ["jabc", "-c", " ; ".join(cmdline)]
80 
81  rc = popen_and_wait_with_timeout(timeout, cmd, shell=False, stdout=sys.stdout, stderr=sys.stderr)
82 
83  if rc != 0:
84  # jabc failed or stopped. Write a status file to update the status to unknown
85  with open(tmplog_name, "w") as f:
86  f.write('snl_UNK -1 unknown\n')
87  f.write('NULL\n')
88  f.write('NULL\n')
89 
90  pyabc.run_command("read_status %s"%tmplog_name)
91 
92  return rc
def popen_and_wait_with_timeout
Definition: reachx_cmd.py:15
def run_reachx_cmd
Definition: reachx_cmd.py:68
def temp_file_name
Definition: reachx_cmd.py:46
def cygpath
Definition: reachx_cmd.py:56
def reachx_cmd.temp_file_name (   suffix = "")

Definition at line 46 of file reachx_cmd.py.

46 
47 def temp_file_name(suffix=""):
48  file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix)
49  name = file.name
50  file.close()
51 
52  try:
53  yield name
54  finally:
55  os.unlink(name)
def temp_file_name
Definition: reachx_cmd.py:46