Beispiel #1
0
def do_exec(code, uid, doctest=False):
    """exec code in a new thread (and isolated environment).
    """
    debug_msg("Entering cometIO.do_exec()", 9)
    # When a security mode is set to "display ...", we only parse the
    # page, but no Python execution from is allowed from that page.
    try:
        pageid = uid.split("_")[0]
        username = names[pageid]
    except:
        debug_msg("error in do_exec; uid =%s"%uid, 8)
        return

    if 'display' in config[username]['_get_current_page_security_level']():
        return
    elif not accounts:  # same if no username/password set
        return

    # make the io widget appear
    output_buffers[pageid].put(show_io_js % (uid, uid, uid))
    debug_msg(" creating an intrepreter instance in cometIO.do_exec()", 9)
    t = interpreter.Interpreter(code, uid, symbols=config[username]['symbols'],
                                doctest=doctest)
    debug_msg(" setting a daemon thread in cometIO.do_exec()", 5)
    t.setDaemon(True)
    debug_msg("  starting the thread in cometIO.do_exec()", 5)
    t.start()
    debug_msg("reached the end of cometIO.do_exec()", 5)
Beispiel #2
0
 def __init__(self, path):
     self.read = reader.Reader(path)
     self.interpret = interpreter.Interpreter()
     self.generator = generator.Generator()
     self.string_accounts = [
         self.read.split_row_columns(i)
         for i in range(0, len(self.read.split_rows()))
     ]
     self.accounts = self.read_accounts()
Beispiel #3
0
    def test_interpret_setting_uploaded_files(self):
        """
        Issue One - Large Class - Test Two
        Tests if can call interpreter to set files
        Author: Braeden
        """
        inter = interpreter.Interpreter()
        inter.do_change_python_files(self.string_multiple_file_upload)

        self.assertTrue(inter.controller.files ==
                        self.array_multiple_file_upload)
Beispiel #4
0
    def test_interpret_output_to_dot(self):
        """
        Issue One - Large Class - Test Three
        Tests if can call interpreter to create DOT file
        Author: Braeden
        """
        inter = interpreter.Interpreter()
        inter.controller.set_files_by_arguments(
            [os.getcwd() + "\\tmp\\plants.py"])
        inter.do_output_to_dot("")

        file_exists = os.path.isfile(os.getcwd() + "\\src\\tmp\\class.dot")

        self.assertTrue(file_exists)
Beispiel #5
0
 def __init__(self):
     self.interpreter = interpreter.Interpreter()
     self.numbers = {
         '0': [1, 2, 3],
         '1': [0, 1, 1],
         '2': [1, 2, 2],
         '3': [1, 2, 2],
         '4': [0, 3, 1],
         '5': [1, 2, 2],
         '6': [1, 2, 3],
         '7': [1, 1, 1],
         '8': [1, 3, 3],
         '9': [1, 3, 2],
     }
Beispiel #6
0
 def setUp(self):
     self.interpreter = interpreter.Interpreter()
Beispiel #7
0
def initiate_python_parser():
    interpreter = pi.Interpreter()
    interpreter.run_console()