Browse Source

Patches to wrapper and MvC

Yentl Van Tendeloo 8 years ago
parent
commit
496bac5615
2 changed files with 12 additions and 12 deletions
  1. 0 1
      core/core_algorithm.alc
  2. 12 11
      wrappers/modelverse.py

+ 0 - 1
core/core_algorithm.alc

@@ -341,7 +341,6 @@ Element function user_function():
 			output("Please repeat the password")
 			if (password == hash(input())):
 				output("Passwords match!")
-				output("User created")
 				instantiate_attribute(core, user_id, "password", password)
 				break!
 			else:

+ 12 - 11
wrappers/modelverse.py

@@ -23,6 +23,7 @@ def _input(value):
     else:
         value = json.dumps(value)
         urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": value, "taskname": taskname}))).read()
+        print("Set input: " + str(value))
 
 def _input_raw(value, taskname):
     # Ugly json encoding of primitives
@@ -65,10 +66,11 @@ def _output(expected=None):
     try:
         global last_output
         last_output = json.loads(urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "taskname": taskname}))).read())
+        print("Got output: " + str(last_output))
     except:
         raise UnknownError()
     if expected is not None and last_output != expected:
-        raise InterfaceMismatch(last_output)
+        raise InterfaceMismatch(_last_output(), expected)
     return last_output
 
 def _last_output():
@@ -156,11 +158,12 @@ def login(username, password):
             raise PermissionDenied()
         else:
             raise InterfaceMismatch(_last_output())
-    elif _output() == "This is a new user: please give password!":
+    elif _last_output() == "This is a new user: please give password!":
         _input(password)
         _output("Please repeat the password")
         _input(password)
-        if _output() == "Welcome to the Model Management Interface v2.0!":
+        if _output() == "Passwords match!":
+            _output("Welcome to the Model Management Interface v2.0!")
             _output("Use the 'help' command for a list of possible commands")
             _output("Ready for command...")
             mode = 2
@@ -461,7 +464,7 @@ def types():
     if mode != 3:
         raise InvalidMode()
     _input("types")
-    _output("List of all types:")
+    _output("List of types:")
     lst = []
     while (_output() != "Please give your command."):
         v = _last_output()
@@ -480,11 +483,10 @@ def read(ID):
     _input("read")
     _output("Element to read?")
     _input(ID)
-    _output("ID: " + str(ID))
-    if _last_output() == "Unknown element; aborting":
+    if _output() == "Unknown element; aborting":
         _output("Please give your command.")
         raise UnknownIdentifier()
-    else:
+    elif _last_output() == "ID: " + str(ID):
         t = _output().split(":")[1].strip()
         if (not _output().startswith("Source:")):
             rval = (t, None)
@@ -506,11 +508,10 @@ def read_attrs(ID):
     _input("read")
     _output("Element to read?")
     _input(ID)
-    _output("ID: " + str(ID))
-    if _last_output() == "Unknown element; aborting":
+    if _output() == "Unknown element; aborting":
         _output("Please give your command.")
         raise UnknownIdentifier()
-    else:
+    elif _last_output() == "ID: " + str(ID):
         rval = {}
         # Skip until attributes
         while (_output() != "Attributes:"):
@@ -611,7 +612,7 @@ def delete_element(ID):
             raise UnknownIdentifier()
         else:
             raise InterfaceMismatch(_last_output())
-    elif _output() == "Permission denied":
+    elif _last_output() == "Permission denied":
         _output("Please give your command.")
         raise PermissionDenied()
     else: