Parcourir la source

Make ports flexible and no longer restricted to 8001: mostly updated tests for this

Yentl Van Tendeloo il y a 9 ans
Parent
commit
80c5157715

+ 8 - 3
compile.sh

@@ -3,9 +3,14 @@ set -e
 
 source library.sh
 
+address=$1
+filename=`realpath $2`
+username=$3
+modulename=$4
+mode=$5
+
 # Leave this here too, as the call might crash early
-curl http://localhost:8001 -d "op=set_input&username=user_manager&element_type=V&value=\"$2\"" -s -S >> /dev/null
+curl $address -d "op=set_input&username=user_manager&element_type=V&value=\"$username\"" -s -S >> /dev/null
 
-f=`realpath $1`
 cd interface/HUTN
-${python} hutn_compiler/compiler.py $f grammars/actionlanguage.g ${4-PO} $2 $3 $f $5
+${python} hutn_compiler/compiler.py $filename grammars/actionlanguage.g $mode $username $modulename $filename $address

+ 2 - 1
hybrid_server/classes/mvkcontroller.xml

@@ -16,6 +16,7 @@
             self.input_queue = defaultdict(list)
             self.output_queue = defaultdict(list)
             self.source = None
+            self.port = int(sys.argv[1])
 
             self.mvs_operations = {
                     "CN": self.mvs.create_node,
@@ -70,7 +71,7 @@
                     <parameter expr="'to_mvi'"/>
                     <parameter expr="'Server'"/>
                     <parameter expr="''"/>
-                    <parameter expr="8001"/>
+                    <parameter expr="self.port"/>
                 </raise>
             </onentry>
             <transition event="instance_created" target="../running">

+ 24 - 19
integration/utils.py

@@ -9,9 +9,10 @@ import urllib
 import urllib2
 import subprocess
 import signal
+import random
 
 username = "test_user"
-parallel_push = True
+parallel_push = False
 
 def serialize(value):
     if isinstance(value, str):
@@ -38,19 +39,19 @@ def kill(process):
     elif os.name == "posix":
         subprocess.call(["pkill", "-P", "%i" % process.pid])
 
-def flush_data(data):
+def flush_data(address, data):
     if data:
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "data": json.dumps(data), "username": username})), timeout=10).read()
+        urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "data": json.dumps(data), "username": username})), timeout=10).read()
     return []
 
-def compile_file(mod_filename, filename, mode, proc):
+def compile_file(address, mod_filename, filename, mode, proc):
     # Load in the file required
     try:
         timeout_val = 120
         import random
         username = str(random.random())
         while 1:
-            proc2 = execute("compile", [mod_filename, username, filename, mode], wait=False)
+            proc2 = execute("compile", [address, mod_filename, username, filename, mode], wait=False)
 
             if proc.returncode is not None:
                 # Modelverse has already terminated, which isn't a good sign!
@@ -84,9 +85,11 @@ def run_file(files, parameters, expected, mode):
     import os.path
 
     time.sleep(0.01)
+    port = random.randint(10000, 10100)
+    address = "http://localhost:%i" % port
     try:
         # Run Modelverse server
-        proc = execute("run_local_modelverse", ["bootstrap/bootstrap.m"], wait=False)
+        proc = execute("run_local_modelverse", [str(port)], wait=False)
 
         threads = []
         for filename in files:
@@ -102,10 +105,10 @@ def run_file(files, parameters, expected, mode):
 
             if parallel_push:
                 import threading
-                threads.append(threading.Thread(target=compile_file, args=[mod_filename, filename, mode, proc]))
+                threads.append(threading.Thread(target=compile_file, args=[address, mod_filename, filename, mode, proc]))
                 threads[-1].start()
             else:
-                compile_file(mod_filename, filename, mode, proc)
+                compile_file(address, mod_filename, filename, mode, proc)
 
         if parallel_push:
             for t in threads:
@@ -113,7 +116,7 @@ def run_file(files, parameters, expected, mode):
 
         if mode[-1] == "O":
             # Fire up the linker
-            val = execute("link_and_load", [username] + files, wait=True)
+            val = execute("link_and_load", [address, username] + files, wait=True)
             if val != 0:
                 raise Exception("Linking error")
 
@@ -125,12 +128,12 @@ def run_file(files, parameters, expected, mode):
                     data.append(["V", serialize(v)])
             else:
                 data.append(["V", serialize(p)])
-        flush_data(data)
+        flush_data(address, data)
         
         for e in expected:
             c = len(e) if isinstance(e, set) else 1
             for _ in range(c):
-                val = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": username})), timeout=10).read()
+                val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=10).read()
 
                 if proc.returncode is not None:
                     # Modelverse has already terminated, which isn't a good sign!
@@ -158,18 +161,20 @@ def run_file(files, parameters, expected, mode):
             pass
             
 def run_barebone(parameters, expected, interface="0", timeout=False, wait=False, link=None):
+    port = random.randint(10000, 10100)
+    address = "http://localhost:%i" % port
     try:
         # Run Modelverse server
-        proc = execute("run_local_modelverse", ["bootstrap/bootstrap.m"], wait=False)
+        proc = execute("run_local_modelverse", [str(port)], wait=False)
 
         # Create user and set interface
         timeout_val = 15
         start = time.time()
         while 1:
             try:
-                urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % username, "username": "user_manager"})), timeout=1).read()
+                urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % username, "username": "user_manager"})), timeout=1).read()
                 if interface is not None:
-                    urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": interface, "username": username})), timeout=1).read()
+                    urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": interface, "username": username})), timeout=1).read()
                 break
             except:
                 time.sleep(0.01)
@@ -187,8 +192,8 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
         for p in parameters:
             if isinstance(p, int):
                 if p not in var_list:
-                    data = flush_data(data)
-                    val = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": username})), timeout=10).read()
+                    data = flush_data(address, data)
+                    val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=10).read()
 
                     if proc.returncode is not None:
                         # Modelverse has already terminated, which isn't a good sign!
@@ -204,13 +209,13 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
                 val = p
                 t = "V"
             data.append([t, val])
-        data = flush_data(data)
+        data = flush_data(address, data)
 
         # Now do linking and loading
         if link is not None:
             # Execute linker
             timeout_val = 10
-            proc2 = execute("link_and_load", [username] + link, wait=False)
+            proc2 = execute("link_and_load", [address, username] + link, wait=False)
 
             while proc2.returncode is None:
                 time.sleep(0.01)
@@ -227,7 +232,7 @@ def run_barebone(parameters, expected, interface="0", timeout=False, wait=False,
             c = len(e) if isinstance(e, set) else 1
             for _ in range(c):
                 try:
-                    val = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": username})), timeout=15).read()
+                    val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username})), timeout=15).read()
                 except:
                     if timeout:
                         return True

+ 20 - 19
interface/HUTN/hutn_compiler/constructors_object_visitor.py

@@ -12,6 +12,7 @@ class ConstructorsObjectVisitor(ConstructorsVisitor):
         self.username = args[0]
         self.obj_file = args[1]
         self.real_file = args[2]
+        self.address = args[3]
 
         self.object_symbols = {}
 
@@ -22,12 +23,12 @@ class ConstructorsObjectVisitor(ConstructorsVisitor):
         self.hash_file = md5.hexdigest()
 
         # Check if file is already compiled (with same hash) in Modelverse
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.username, "username": "user_manager"}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"is_defined"', "username": self.username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.username, "username": "user_manager"}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"is_defined"', "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
 
-        v = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": self.username}))).read()
+        v = urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "get_output", "username": self.username}))).read()
         v = v.split("=", 2)[2]
         if v == "None":
             # Not defined, so recompile
@@ -38,9 +39,9 @@ class ConstructorsObjectVisitor(ConstructorsVisitor):
                 print("[COMPILE] %s" % self.real_file.rsplit("/", 1)[1])
 
                 # Remove in Modelverse and recompile
-                urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
-                urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"remove_obj"', "username": self.username}))).read()
-                urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
+                urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
+                urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"remove_obj"', "username": self.username}))).read()
+                urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
             else:
                 self.visit = lambda i: i
                 self.dump = lambda: True
@@ -51,17 +52,17 @@ class ConstructorsObjectVisitor(ConstructorsVisitor):
 
         import json
         # Set up interface
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
 
         # Start uploading the code
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"upload"', "username": self.username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.hash_file, "username": self.username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": 'true', "username": self.username}))).read() # Use new interface
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"upload"', "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.hash_file, "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": 'true', "username": self.username}))).read() # Use new interface
 
         def flush_data(data):
             if data:
-                urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "data": json.dumps(data), "username": self.username})), timeout=timeout).read()
+                urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "data": json.dumps(data), "username": self.username})), timeout=timeout).read()
             return []
 
         var_list = {}
@@ -70,7 +71,7 @@ class ConstructorsObjectVisitor(ConstructorsVisitor):
             if isinstance(p, int):
                 if p not in var_list:
                     data = flush_data(data)
-                    val = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": self.username})), timeout=timeout).read()
+                    val = urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "get_output", "username": self.username})), timeout=timeout).read()
                     val = val.split("=", 2)[1].split("&", 1)[0]
                     var_list[p] = val
                     continue
@@ -89,14 +90,14 @@ class ConstructorsObjectVisitor(ConstructorsVisitor):
             data.append(["V", "true"])
             data.append(["V", '"%s"' % e])
             data.append(["V", "true" if v else "false"])
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "data": json.dumps(data), "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "data": json.dumps(data), "username": self.username}))).read()
 
         # Finish the symbol table
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": 'false', "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": 'false', "username": self.username}))).read()
 
         # Wait for kernel to signal that it finished
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '2', "username": self.username}))).read()
-        v = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '2', "username": self.username}))).read()
+        v = urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "get_output", "username": self.username}))).read()
         v = v.split("=", 2)[2]
         if v == "DONE":
             return True

+ 14 - 13
interface/HUTN/hutn_compiler/linker.py

@@ -2,7 +2,7 @@ import sys
 import urllib
 import urllib2
 
-def link(username, objects, fast):
+def link(address, username, objects, fast):
     # Read out all symbol tables that are to be linked
     definers = {}
     users = {}
@@ -10,11 +10,11 @@ def link(username, objects, fast):
         definers["main"] = None
         for obj in objects:
             print("[SYMB] %s" % (obj))
-            urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": username}))).read()
-            urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"read_symbols"', "username": username}))).read()
-            urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % obj, "username": username}))).read()
+            urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": username}))).read()
+            urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"read_symbols"', "username": username}))).read()
+            urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % obj, "username": username}))).read()
 
-            v = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": username}))).read()
+            v = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username}))).read()
             lst = v.rsplit("=", 1)[1]
             lst = lst.split("\n")
             for e in lst:
@@ -40,10 +40,10 @@ def link(username, objects, fast):
     initializers = []
     for obj in objects:
         print("[LINK] %s" % (obj))
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"read_initializers"', "username": username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % obj, "username": username}))).read()
-        v = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": username}))).read()
+        urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": username}))).read()
+        urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"read_initializers"', "username": username}))).read()
+        urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % obj, "username": username}))).read()
+        v = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "username": username}))).read()
         start = str(v.split("&", 1)[0].split("=")[1])
         initializers.append(start)
 
@@ -82,13 +82,14 @@ def link(username, objects, fast):
             ])
 
     import json
-    urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "data": json.dumps(commands), "username": username}))).read()
+    urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "data": json.dumps(commands), "username": username}))).read()
 
 if len(sys.argv) == 1:
     print("No username defined")
 else:
-    username = sys.argv[1]
-    objects = set(sys.argv[2:])
+    address = sys.argv[1]
+    username = sys.argv[2]
+    objects = set(sys.argv[3:])
     if "--fast" in objects:
         objects.remove("--fast")
         fast = True
@@ -96,6 +97,6 @@ else:
         fast = False
 
     if objects:
-        link(username, objects, fast)
+        link(address, username, objects, fast)
     else:
         print("No files to link defined")

+ 19 - 18
interface/HUTN/hutn_compiler/primitives_object_visitor.py

@@ -11,6 +11,7 @@ class PrimitivesObjectVisitor(PrimitivesVisitor):
         self.username = args[0]
         self.obj_file = args[1]
         self.real_file = args[2]
+        self.address = args[3]
 
         self.object_symbols = {}
 
@@ -21,12 +22,12 @@ class PrimitivesObjectVisitor(PrimitivesVisitor):
         self.hash_file = md5.hexdigest()
 
         # Check if file is already compiled (with same hash) in Modelverse
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.username, "username": "user_manager"}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"is_defined"', "username": self.username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.username, "username": "user_manager"}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"is_defined"', "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
 
-        v = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": self.username}))).read()
+        v = urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "get_output", "username": self.username}))).read()
         v = v.split("=", 2)[2]
         if v == "None":
             # Not defined, so recompile
@@ -37,9 +38,9 @@ class PrimitivesObjectVisitor(PrimitivesVisitor):
                 print("[COMPILE] %s" % self.real_file.rsplit("/", 1)[1])
 
                 # Remove in Modelverse and recompile
-                urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
-                urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"remove_obj"', "username": self.username}))).read()
-                urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
+                urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
+                urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"remove_obj"', "username": self.username}))).read()
+                urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
             else:
                 self.visit = lambda i: i
                 self.dump = lambda: True
@@ -50,14 +51,14 @@ class PrimitivesObjectVisitor(PrimitivesVisitor):
 
         import json
         # Set up interface
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '3', "username": self.username}))).read()
 
         # Start uploading the code
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"upload"', "username": self.username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.hash_file, "username": self.username}))).read()
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": 'false', "username": self.username}))).read() # Use old interface
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": json.dumps(v), "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"upload"', "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.obj_file, "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '"%s"' % self.hash_file, "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": 'false', "username": self.username}))).read() # Use old interface
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": json.dumps(v), "username": self.username}))).read()
 
         # Upload symbol table
         data = []
@@ -65,14 +66,14 @@ class PrimitivesObjectVisitor(PrimitivesVisitor):
             data.append(["V", "true"])
             data.append(["V", '"%s"' % e])
             data.append(["V", "true" if v else "false"])
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "data": json.dumps(data), "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "data": json.dumps(data), "username": self.username}))).read()
 
         # Finish the symbol table
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": 'false', "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": 'false', "username": self.username}))).read()
 
         # Wait for kernel to signal that it finished
-        urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "set_input", "element_type": "V", "value": '2', "username": self.username}))).read()
-        v = urllib2.urlopen(urllib2.Request("http://localhost:8001/", urllib.urlencode({"op": "get_output", "username": self.username}))).read()
+        urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "set_input", "element_type": "V", "value": '2', "username": self.username}))).read()
+        v = urllib2.urlopen(urllib2.Request(self.address, urllib.urlencode({"op": "get_output", "username": self.username}))).read()
         v = v.split("=", 2)[2]
         if v == "DONE":
             return True

+ 5 - 3
link_and_load.sh

@@ -1,8 +1,10 @@
 #!/bin/bash
 set -e
-username=$1
+address=$1
+username=$2
+shift
 shift
 
-curl http://localhost:8001 -d "op=set_input&username=user_manager&element_type=V&value=\"$username\"" -s -S >> /dev/null
+curl $address -d "op=set_input&username=user_manager&element_type=V&value=\"$username\"" -s -S >> /dev/null
 
-python interface/HUTN/hutn_compiler/linker.py $username "$@"
+python interface/HUTN/hutn_compiler/linker.py $address $username "$@"

+ 4 - 2
make_all.sh

@@ -2,11 +2,13 @@
 set -e
 
 username=$1
+address=$2
+shift
 shift
 
 for f in "$@"
 do
-    ./compile.sh $f $RANDOM $f CO
+    ./compile.sh $address $f $RANDOM $f CO
 done
 
-./link_and_load.sh $username "$@"
+./link_and_load.sh $address $username "$@"

+ 4 - 2
make_parallel.sh

@@ -2,11 +2,13 @@
 set -e
 
 username=$1
+address=$2
+shift
 shift
 
 for f in "$@"
 do
-    ./compile.sh $f $RANDOM $f PO --debug &
+    ./compile.sh $address $f $RANDOM $f PO --debug &
 done
 
 for job in `jobs -p`
@@ -14,4 +16,4 @@ do
     wait $job || let "FAIL+=1"
 done
 
-./link_and_load.sh $username "$@" --fast
+./link_and_load.sh $address $username "$@" --fast

+ 2 - 2
run_local_modelverse.sh

@@ -2,7 +2,7 @@
 set -e
 trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
 
-filename=`realpath ${1-bootstrap/bootstrap.m}`
+port=$1
 source library.sh
 
 echo "Compiling MvK server"
@@ -10,4 +10,4 @@ cd hybrid_server
 ${python} python_sccd_compiler/sccdc.py -p threads server.xml
 
 echo "Starting MvK"
-${python} run_mvk_server.py ${filename}
+${python} run_mvk_server.py $port