def run_it():
     import run
     try:
         run.execute(policy, prog_args)
         mainwindow.destroy()
     except SafeException, ex:
         box = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
                                 gtk.BUTTONS_OK, str(ex))
         box.run()
         box.destroy()
         mainwindow.show()
Exemple #2
0
def test():
    # path = os.path.join("../temp", "folder")
    # os.mkdir(path)
    # filepath = os.path.join(path, "input.txt")
    #         #i = open(path +"/input.txt", "w+")
    # i = open(filepath, "w+")
    # i.write('input')
    # outputFile = os.path.join("temp", 'folder', "output.txt")
    # f = open(outputFile, "w+")
    # f.close()
    # command = 'run.py ../temp/' + 'folder' +'/source.' + 'py' + ' ' + 'python3' + ' '  + '5'
    path = os.path.join("../temp", 'folder')
    f = open(path + '/source.' + extensions['python3'], "w")
    f.write('print(\"hello world\")')
    f.close()
    cm = os.path.join("../temp", 'folder', "source.py")
    file = os.path.join("../temp", 'folder', "source." + extensions['python3'])
    res = execute(file, 'python3', 5)
    result = {
        'output': res[0],
        'code': res[1],
        'status': codes[res[1]],
        'submission_id': 'jkfnrdj99'
    }
    result = json.dumps(result)
    print(result)
Exemple #3
0
    def startCapture(self, actionList):

        if (len(actionList) == 0):
            QMessageBox.about(QWidget(), "Error",
                              "What are you doing? There are no actions!!!")
            return

        ifModules = []

        for action in actionList:
            if action is None:
                continue

            components = {}
            components["module"] = action.getAlgo().replace(" ", "")
            ifCondition = action.getIfCondition().replace(" ", "")
            components["var"] = ifCondition

            if ifCondition == "":
                components["comp"] = ""
                components["eq"] = action.getTags()
            elif 'Is' not in ifCondition:
                components["comp"] = action.getComparisonOperator().replace(
                    " ", "")
                components["eq"] = action.getEquality()
            else:
                components["comp"] = "="
                components["eq"] = action.getBooleanSelect().replace(" ", "")
            components["expression"] = action.getThenCondition().replace(
                " ", "")
            components["time"] = action.getTimeInterval()
            print components

            ifModules.append(ifCreator.createIF(components))
        '''
        print "pressed start"
        self.capturing = True
        cap = self.c
        while(self.capturing):
            ret, frame = cap.read()
            cv2.imshow("Capture", frame)
            cv2.waitKey(5)
        cv2.destroyAllWindows()
        '''

        run.execute(ifModules)
 def test_execute_server(self, mock_ioloop_start):
     mock_routes = mock.Mock()
     run.execute(mock_routes)
     self.assertEquals(mock_ioloop_start.call_count, 1)
 def test_execute_minus(self):
     self.assertEqual(0, run.execute(-1))
 def test_execute(self):
     self.assertEqual(2, run.execute(1))
Exemple #7
0
def run(id, algorithm, env, episodes, timesteps, update_cadence, seed, lr, epsilon, gamma):
    start = time()
    name = "{}: {}-{} (L: {}, G: {})".format(id, algorithm, env, lr, gamma)
    print("Starting {}".format(name))
    execute(algorithm, env, episodes, timesteps, update_cadence, seed, lr, epsilon, gamma=gamma, silent=True)
    print("Finished {} in {} seconds".format(name, time() - start))
def compute_tags_assignments(stations, events):
    return execute(stations, events)
 def test_execute_success(self, mock_connect):
     fetch_function = mock.MagicMock(return_value=MOCK_QUERY_RESULT)
     mock_connect.return_value = mock_connection(
         fetch_function=fetch_function)
     cursor = run.execute("")
     self.assertEquals(cursor.fetchall(), MOCK_QUERY_RESULT)
 def test_execute_failed(self, mock_connect):
     execution_function = mock.MagicMock(return_value=MOCK_QUERY_RESULT)
     execution_function.side_effect = [Exception()]
     mock_connect.return_value = mock_connection(execution_function)
     self.assertRaises(custom_exceptions.SQLExecutionError,
                       lambda: run.execute(""))
 def test_connection_failed(self, mock_connection):
     mock_connection.side_effect = [Exception()]
     self.assertRaises(custom_exceptions.SQLConnectionError,
                       lambda: run.execute(""))
Exemple #12
0
 def test_execute_production_server(self, mock_flask_run):
     run.execute(False)
     mock_flask_run.assert_called_with(host="0.0.0.0",
                                       port=PORT,
                                       debug=False)
Exemple #13
0
 def test_execute_debug_server(self, mock_flask_run):
     run.execute(True)
     mock_flask_run.assert_called_with(host="0.0.0.0",
                                       port=PORT,
                                       debug=True)
Exemple #14
0
 def test_expect_false(self):
     self.assertEqual(3, run.execute(2))
Exemple #15
0
 def test_executeTwo(self):
     self.assertEqual(2, run.execute(2))