|
@@ -5,6 +5,8 @@ import urllib
|
|
|
import subprocess
|
|
|
import time
|
|
|
|
|
|
+TIMEOUT = 10
|
|
|
+
|
|
|
def do_compile(address, filename, taskname, modulename, mode, optionals=['--debug'], grammar=""):
|
|
|
filename = os.path.realpath(filename)
|
|
|
if grammar == "":
|
|
@@ -16,12 +18,16 @@ def do_compile(address, filename, taskname, modulename, mode, optionals=['--debu
|
|
|
grammar = "grammars/actionlanguage.g"
|
|
|
|
|
|
# Create new task
|
|
|
- try:
|
|
|
- urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % taskname, "taskname": "task_manager"}))).read()
|
|
|
- subprocess.check_call([sys.executable, "hutn_compiler/compiler.py", filename, grammar, mode, taskname, modulename, filename, address] + optionals, cwd="interface/HUTN")
|
|
|
- return 0
|
|
|
- except:
|
|
|
- return 1
|
|
|
+ start = time.time()
|
|
|
+ while time.time() - start < TIMEOUT:
|
|
|
+ try:
|
|
|
+ urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % taskname, "taskname": "task_manager"}))).read()
|
|
|
+ break
|
|
|
+ except:
|
|
|
+ # Try again
|
|
|
+ continue
|
|
|
+ subprocess.check_call([sys.executable, "hutn_compiler/compiler.py", filename, grammar, mode, taskname, modulename, filename, address] + optionals, cwd="interface/HUTN")
|
|
|
+ return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
if len(sys.argv) != 6:
|