(graph, timeout)
| 23 | |
| 24 | |
| 25 | def issue_queries(graph, timeout): |
| 26 | os.environ["PATH"] = os.pathsep.join([ENV['PATH'], site.getuserbase() + '/bin']) |
| 27 | os.environ["PYTHONPATH"] = os.pathsep.join([ENV['PYTHONPATH'], HERE + "/generator"]) |
| 28 | cmd = ["grammarinator-generate", "CustomCypherGenerator.CustomCypherGenerator", |
| 29 | "--sys-path", "generator/", "--jobs", "1", "-r", "oC_Query", "--stdout", "-d", "30"] |
| 30 | |
| 31 | start = time() |
| 32 | while time() - start < timeout: |
| 33 | # Capture generated queries |
| 34 | try: |
| 35 | query = subprocess.check_output(cmd, encoding="utf8") |
| 36 | except subprocess.CalledProcessError as e: |
| 37 | # Subprocess failed, emit the thrown exception and retry |
| 38 | print(str(e)) |
| 39 | continue |
| 40 | |
| 41 | # Log query to console |
| 42 | print(query) |
| 43 | try: |
| 44 | graph.query(query, timeout=1000) |
| 45 | except ResponseError as e: |
| 46 | print("Encountered exception: %s" % str(e)) |
| 47 | except ConnectionError as e: |
| 48 | # The previous query crashed the server, exit with exception |
| 49 | raise(e) |
| 50 | |
| 51 | |
| 52 | parser = argparse.ArgumentParser() |
no test coverage detected