Browse Source

Users can never be removed

Yentl Van Tendeloo 8 years ago
parent
commit
0abcd1ef0c

BIN
bootstrap/bootstrap.m.gz


+ 18 - 22
bootstrap/user_manager.alc

@@ -10,26 +10,22 @@ Void function user_management():
 	
 	
 	while (True):
 	while (True):
 		username = input()
 		username = input()
-		if (string_startswith(username, "__")):
-			username = string_substr(username, 2, string_len(username) - 1)
-			dict_delete(read_root(), username)
-		else:
-			if (bool_not(dict_in(read_root(), username))):
-				user_root = create_node()
-				user_frame = create_node()
-				output_value = create_node()
-				input_value = create_node()
-				dict_add(user_root, "frame", user_frame)
-				dict_add(user_root, "globals", create_node())
-				dict_add(user_root, "output", output_value)
-				dict_add(user_root, "last_output", output_value)
-				dict_add(user_root, "input", input_value)
-				dict_add(user_root, "last_input", input_value)
-				dict_add(user_frame, "evalstack", create_node())
-				dict_add(user_frame, "returnvalue", create_node())
-				dict_add(user_frame, "phase", "init")
-				dict_add(user_frame, "IP", dict_read(dict_read(read_root(), "__hierarchy"), "__IP"))
-				dict_add(user_frame, "symbols", create_node())
+		if (bool_not(dict_in(read_root(), username))):
+			user_root = create_node()
+			user_frame = create_node()
+			output_value = create_node()
+			input_value = create_node()
+			dict_add(user_root, "frame", user_frame)
+			dict_add(user_root, "globals", create_node())
+			dict_add(user_root, "output", output_value)
+			dict_add(user_root, "last_output", output_value)
+			dict_add(user_root, "input", input_value)
+			dict_add(user_root, "last_input", input_value)
+			dict_add(user_frame, "evalstack", create_node())
+			dict_add(user_frame, "returnvalue", create_node())
+			dict_add(user_frame, "phase", "init")
+			dict_add(user_frame, "IP", dict_read(dict_read(read_root(), "__hierarchy"), "__IP"))
+			dict_add(user_frame, "symbols", create_node())
 
 
-				//Add this only at the end, as otherwise the user will already be detected
-				dict_add(read_root(), username, user_root)
+			//Add this only at the end, as otherwise the user will already be detected
+			dict_add(read_root(), username, user_root)

+ 38 - 35
kernel/modelverse_kernel/main.py

@@ -43,45 +43,48 @@ class ModelverseKernel(object):
 
 
     def execute_rule(self, username):
     def execute_rule(self, username):
         user_root, =    yield [("RD", [self.root, username])]
         user_root, =    yield [("RD", [self.root, username])]
-        user_frame, =   yield [("RD", [user_root, "frame"])]
-        self.inst, phase =   yield [("RD", [user_frame, "IP"]),
-                               ("RD", [user_frame, "phase"]),
-                              ]
-        self.new_debug, self.phase_v, inst_v = \
-                        yield [("RD", [self.inst, "__debug"]),
-                               ("RV", [phase]),
-                               ("RV", [self.inst]),
-                              ]
-        if self.new_debug is not None:
-            self.debug_info, = yield [("RV", [self.new_debug])]
-
-        if self.phase_v == "finish":
-            gen = self.helper_init(user_root)
-        elif self.inst is None:
-            raise Exception("Instruction pointer could not be found for user %s!" % username)
-        elif isinstance(self.phase_v, string_types):
-            if self.phase_v == "init" and self.inst in self.compiled:
-                #print("%-30s(%s)" % ("COMPILED " + str(self.compiled[self.inst]), self.phase_v))
-                gen = self.execute_primitive(user_root, self.inst, username)
+        if user_root is not None:
+            user_frame, =   yield [("RD", [user_root, "frame"])]
+            self.inst, phase =   yield [("RD", [user_frame, "IP"]),
+                                   ("RD", [user_frame, "phase"]),
+                                  ]
+            self.new_debug, self.phase_v, inst_v = \
+                            yield [("RD", [self.inst, "__debug"]),
+                                   ("RV", [phase]),
+                                   ("RV", [self.inst]),
+                                  ]
+            if self.new_debug is not None:
+                self.debug_info, = yield [("RV", [self.new_debug])]
+
+            if self.phase_v == "finish":
+                gen = self.helper_init(user_root)
+            elif self.inst is None:
+                raise Exception("Instruction pointer could not be found for user %s!" % username)
+            elif isinstance(self.phase_v, string_types):
+                if self.phase_v == "init" and self.inst in self.compiled:
+                    #print("%-30s(%s)" % ("COMPILED " + str(self.compiled[self.inst]), self.phase_v))
+                    gen = self.execute_primitive(user_root, self.inst, username)
+                elif inst_v is None:
+                    raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, self.phase_v))
+                else:
+                    #print("%-30s(%s) -- %s" % (inst_v["value"], self.phase_v, username))
+                    gen = getattr(self, "%s_%s" % (inst_v["value"], self.phase_v))(user_root)
             elif inst_v is None:
             elif inst_v is None:
                 raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, self.phase_v))
                 raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, self.phase_v))
+            elif inst_v["value"] == "call":
+                #print("%-30s(%s)" % ("call", "param"))
+                gen = self.call_param(user_root)
             else:
             else:
-                #print("%-30s(%s) -- %s" % (inst_v["value"], self.phase_v, username))
-                gen = getattr(self, "%s_%s" % (inst_v["value"], self.phase_v))(user_root)
-        elif inst_v is None:
-            raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, self.phase_v))
-        elif inst_v["value"] == "call":
-            #print("%-30s(%s)" % ("call", "param"))
-            gen = self.call_param(user_root)
-        else:
-            raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, self.phase_v))
+                raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, self.phase_v))
 
 
-        try:
-            inp = None
-            while 1:
-                inp = yield gen.send(inp)
-        except StopIteration:
-            pass
+            try:
+                inp = None
+                while 1:
+                    inp = yield gen.send(inp)
+            except StopIteration:
+                pass
+        else:
+            print("Trying to execute non-existing user %s; ignored" % username)
 
 
     ##########################
     ##########################
     ### Process primitives ###
     ### Process primitives ###

+ 1 - 4
kernel/mvk_server/server.py

@@ -1,7 +1,7 @@
 """
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
 
-Date:   Thu Feb  9 13:03:43 2017
+Date:   Thu Feb  9 14:45:08 2017
 
 
 Model author: Yentl Van Tendeloo
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
 Model name:   MvK Server
@@ -270,7 +270,6 @@ class MvKController(RuntimeClassBase):
         data = parameters[1]
         data = parameters[1]
         # No JSON encoding necessary, as it is not complex
         # No JSON encoding necessary, as it is not complex
         try:
         try:
-            print 'from_mvi %s' % data
             args = None
             args = None
             if data["op"] == "set_input":
             if data["op"] == "set_input":
                 if "value" in data:
                 if "value" in data:
@@ -1471,8 +1470,6 @@ class Executor(RuntimeClassBase):
         self.returnpath, username, operation, params, self.request_id = self.request_queue.pop(0)
         self.returnpath, username, operation, params, self.request_id = self.request_queue.pop(0)
         reply = None
         reply = None
         commands = []
         commands = []
-        if operation == "set_input":
-            print("Add input " + str(params))
         while 1:
         while 1:
             commands = self.mvk.execute_yields(username, operation, params, reply)
             commands = self.mvk.execute_yields(username, operation, params, reply)
             if commands is None:
             if commands is None: