def batch_mode(input_file_path: str, output_file_path: str) -> None: """ batch_mode Process regex and test strings in batch mode. Output results to output_file_path. :param input_file_path: The input JSON file path. :param output_file_path: The output JSON file path. """ # read the input file and get an object representation of it. regex_result_list = JsonReader(input_file_path).regex_input_list if not regex_result_list: logging.critical( f'Batch mode failed: {input_file_path} in improper format.') return # Run all test strings. _run_all_test_strings_in_list(regex_result_list) # Write results to the output_file_path JsonWriter().write_json_output_file(output_file_path, regex_result_list) logging.info('Batch mode completed on input file ' + str(input_file_path) + ' and output file ' + str(output_file_path))
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.nextWorkerInput = ["[]", "1"] self.bestPropScore = -1 self.clear_worker_table() self.DataCollector = JsonReader(self) self.connect(self.DataCollector, QtCore.SIGNAL("received_data"), self.received) self.connect(self.DataCollector, QtCore.SIGNAL("worker_updated"), self.update_worker) self.connect(self.DataCollector, QtCore.SIGNAL("round_started"), self.start_round) self.connect(self.DataCollector, QtCore.SIGNAL("worker_input_changed"), self.update_worker_input) self.connect(self.DataCollector, QtCore.SIGNAL("problem_state_changed"), self.update_problem_state) self.connect(self.DataCollector, QtCore.SIGNAL("all_data"), self.update_all) self.DataCollector.start() # proposition tab QtCore.QObject.connect(self.ui.cbxId, QtCore.SIGNAL("currentIndexChanged(int)"), self.cbxId_indexChanged) self.paintBox = PaintBox(self.ui.tabProposition) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.paintBox.sizePolicy().hasHeightForWidth()) self.paintBox.setSizePolicy(sizePolicy) self.ui.gridLayout_4.addWidget(self.paintBox, 1, 0, 1, 1) # io tab QtCore.QObject.connect(self.ui.btnSend, QtCore.SIGNAL("clicked()"), self.btnSend_clicked) QtCore.QObject.connect(self.ui.edtSend, QtCore.SIGNAL("returnPressed()"), self.btnSend_clicked)
from flask import Flask from flask import redirect, url_for, request, render_template from werkzeug.exceptions import NotFound from jsonreader import JsonReader app = Flask(__name__) posts_data = JsonReader() @app.route('/') def index(): params = { 'footer_needed': False, } return render_template('index.html', **params) @app.route('/posts/') def posts(): params = { 'footer_needed': True, 'footer_address_needed': False, 'posts_count': posts_data.getPostCount(), 'posts': posts_data.getPostsList(), } return render_template('posts.html', **params) @app.route('/posts/global_<int:fromID>_<int:postID>/') def posts_postID(fromID, postID): params = {
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) # status bar self.labelProblemSpec = QtGui.QLabel() self.labelProblemTime = QtGui.QLabel() self.labelCurrentRound = QtGui.QLabel() self.labelWorkerInput = QtGui.QLabel() self.ui.statusbar.addWidget(self.labelProblemSpec, 1) self.ui.statusbar.addWidget(self.labelProblemTime, 1) self.ui.statusbar.addWidget(self.labelCurrentRound, 1) self.ui.statusbar.addWidget(self.labelWorkerInput, 1) # set menu shortcuts self.ui.actionLoadGameState.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+O"))) self.ui.actionSaveGameState.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+S"))) self.ui.actionQuit.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+Q"))) self.ui.actionStartRound.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+R"))) self.ui.actionAddScores.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+A"))) self.ui.actionKillAllWorkers.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+K"))) self.DataCollector = JsonReader(self) self.connect(self.DataCollector, QtCore.SIGNAL("received_data"), self.received) self.connect(self.DataCollector, QtCore.SIGNAL("worker_updated"), self.update_worker) self.connect(self.DataCollector, QtCore.SIGNAL("round_started"), self.start_round) self.connect(self.DataCollector, QtCore.SIGNAL("round_ended"), self.end_round) self.connect(self.DataCollector, QtCore.SIGNAL("worker_input_changed"), self.update_worker_input) self.connect(self.DataCollector, QtCore.SIGNAL("problem_chosen"), self.choose_problem) self.connect(self.DataCollector, QtCore.SIGNAL("all_data"), self.update_all) self.connect(self.DataCollector, QtCore.SIGNAL("save_game_state_reply"), self.save_game_state_reply) self.connect(self.DataCollector, QtCore.SIGNAL("load_game_state_reply"), self.load_game_state_reply) self.DataCollector.start() self.problemAnswerTime = 0 self.roundTimerRemaining = 0 self.roundTimer = QtCore.QTimer() QtCore.QObject.connect(self.roundTimer, QtCore.SIGNAL("timeout()"), self.roundTimer_tick) # file menu QtCore.QObject.connect(self.ui.actionLoadGameState, QtCore.SIGNAL("triggered()"), self.btnLoadGameState_clicked) QtCore.QObject.connect(self.ui.actionSaveGameState, QtCore.SIGNAL("triggered()"), self.btnSaveGameState_clicked) QtCore.QObject.connect(self.ui.actionReloadAllData, QtCore.SIGNAL("triggered()"), self.btnReloadAllData_clicked) QtCore.QObject.connect(self.ui.actionQuit, QtCore.SIGNAL("triggered()"), self.btnQuit_clicked) # round menu QtCore.QObject.connect(self.ui.actionStartRound, QtCore.SIGNAL("triggered()"), self.btnStartRound_clicked) QtCore.QObject.connect(self.ui.actionAddScores, QtCore.SIGNAL("triggered()"), self.btnAddScores_clicked) QtCore.QObject.connect(self.ui.actionKillAllWorkers, QtCore.SIGNAL("triggered()"), self.btnKillAllWorkers_clicked) # worker tab self.ui.tableWorker.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.ui.tableWorker.customContextMenuRequested.connect(self.tableWorker_requestContextMenu) # io tab QtCore.QObject.connect(self.ui.btnSend, QtCore.SIGNAL("clicked()"), self.btnSend_clicked) QtCore.QObject.connect(self.ui.edtSend, QtCore.SIGNAL("returnPressed()"), self.btnSend_clicked) # worker table header thh = self.ui.tableWorker.horizontalHeader() thh.setVisible(True) thh.resizeSection(0, 50) # ranking group thh.resizeSection(1, 60) # id thh.resizeSection(2, 170) # name thh.resizeSection(3, 230) # proposition thh.resizeSection(4, 100) # points thh.resizeSection(5, 50) # processed points thh.resizeSection(6, 100) # problem points (accumulated over all rounds on this problem) thh.setSortIndicator(1, QtCore.Qt.AscendingOrder) tvh = self.ui.tableWorker.verticalHeader() tvh.setVisible(True) tvh.setResizeMode(QtGui.QHeaderView.Fixed) self.reset_problem_list([]) self.worker_blocked = {}