예제 #1
0
def test_invalid_json_action():
    input1 = {"act": "jump", "time": 100}
    input1_json = json.dumps(input1)

    actions = Actions(conn)

    with pytest.raises(KeyError):
        actions.add_action(input1_json)
예제 #2
0
 def __init__(self, rbc, kb, vision_display=False, socket=False):
     self.rbc = rbc
     self.kb = kb
     self.vision_display = vision_display
     self.socket = socket
     if self.socket:
         self._socket_connect()
     self.tasks = Tasks(self.rbc, self.socket, self.vision_display)
     self.actions = Actions(self.rbc)
예제 #3
0
def test_add_jump_action():
    input1 = {"action": "jump", "time": 100}
    input1_json = json.dumps(input1)

    actions = Actions(conn)
    actions.add_action(input1_json)
    cur.execute("select count(*) from actions")
    result = cur.fetchone()
    count = result[0]
    assert count == 1
예제 #4
0
    def __init__(self, drawer):
        """Initialization commands class."""
        self.drawer = drawer
        self.phrases = self.drawer.phrases
        self.message = Message(self.drawer)
        self.notes = Notes(self.message, self.phrases)
        self.config = self.drawer.config
        self.config.checker(self.message, self.phrases)
        self.tree = Tree()
        self.actions = Actions(self.tree, self.notes)

        self.set_window()
예제 #5
0
 def __init__(self, rbc, url, socket, vision_display = False):
     self.rbc = rbc
     self.vision_display = vision_display
     self.socket = socket
     if self.socket:
         self._socket_connect()
     self.tasks = Tasks(self.rbc, self.socket, self.vision_display)
     self.actions = Actions(self.rbc)
     
     websocket.enableTrace(False)
     self.ws = websocket.WebSocketApp(url,
         on_message = lambda ws, msg: self.on_command(ws, msg),
         on_open = lambda ws: self.on_open(ws),
         on_error = lambda ws, msg: self.on_error(ws, msg),
         on_close = lambda ws: self.on_close(ws))
     _thread.start_new_thread(self.ws.run_forever,())
예제 #6
0
def test_get_stats():
    input1 = {"action": "jump", "time": 100}
    input1_json = json.dumps(input1)
    input2 = {"action": "run", "time": 75}
    input2_json = json.dumps(input2)
    input3 = {"action": "jump", "time": 200}
    input3_json = json.dumps(input3)

    actions = Actions(conn)
    actions.add_action(input1_json)
    actions.add_action(input2_json)
    actions.add_action(input3_json)

    results_json = actions.get_stats()
    results = json.loads(results_json)

    jump_dict = list(filter(lambda dict: dict["action"] == "jump", results))[0]
    run_dict = list(filter(lambda dict: dict["action"] == "run", results))[0]

    assert jump_dict["avg"] == 150
    assert run_dict["avg"] == 75
예제 #7
0
    def setup_ui(self):
        self.setObjectName("self")
        self.setFixedSize(287, 235)

        self.actionsMenu = Actions()
        self.default = DefaultSettings
        self.cs = CameraSettings()
        self.path = ""

        # Gain:

        self.selfLayoutWidget = QtWidgets.QWidget(self)
        self.selfLayoutWidget.setGeometry(QtCore.QRect(10, 10, 271, 221))
        self.selfLayoutWidget.setObjectName("selfLayoutWidget")
        self.selfLayout = QtWidgets.QFormLayout(self.selfLayoutWidget)
        self.selfLayout.setContentsMargins(0, 0, 0, 0)
        self.selfLayout.setObjectName("selfLayout")
        self.label = QtWidgets.QLabel(self.selfLayoutWidget)
        self.label.setObjectName("label")
        self.selfLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label)

        self.comboBox = QtWidgets.QComboBox(self.selfLayoutWidget)

        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.comboBox.sizePolicy().hasHeightForWidth())
        self.comboBox.setSizePolicy(sizePolicy)
        self.comboBox.setObjectName("comboBox")

        # TODO ?(x2, x4, x8)?
        self.comboBox.addItems([self.tr("1"), self.tr("2"), self.tr("4")])
        self.comboBox.setCurrentIndex(int(self.cs.gain))

        # Gain
        '''
        Gain/Temperature
        '''
        # Temperature:

        self.selfLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.comboBox)
        self.label_2 = QtWidgets.QLabel(self.selfLayoutWidget)
        self.label_2.setObjectName("label_2")
        self.selfLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2)

        self.lineEdit = QtWidgets.QLineEdit(self.selfLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
        self.lineEdit.setSizePolicy(sizePolicy)
        self.lineEdit.setObjectName("lineEdit")
        self.lineEdit.setValidator(QtGui.QIntValidator(-70, 25))
        self.lineEdit.setText(self.cs.temp)

        # Temperature
        '''
        Temperature/Shooting Time
        '''
        # Shooting Time:

        self.selfLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.lineEdit)
        self.label_3 = QtWidgets.QLabel(self.selfLayoutWidget)
        self.label_3.setObjectName("label_3")
        self.selfLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_3)

        self.lineEdit_2 = QtWidgets.QLineEdit(self.selfLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_2.sizePolicy().hasHeightForWidth())
        self.lineEdit_2.setSizePolicy(sizePolicy)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.lineEdit_2.setValidator(QtGui.QIntValidator(60, 600))
        self.lineEdit_2.setText(self.cs.time_shooting)

        # Shooting Time
        '''
        Shooting Time/Time Between Images 
        '''
        # Time Between Images:

        self.selfLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.lineEdit_2)
        self.label_4 = QtWidgets.QLabel(self.selfLayoutWidget)
        self.label_4.setObjectName("label_4")
        self.selfLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.label_4)

        self.lineEdit_3 = QtWidgets.QLineEdit(self.selfLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_3.sizePolicy().hasHeightForWidth())
        self.lineEdit_3.setSizePolicy(sizePolicy)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.lineEdit_3.setValidator(QtGui.QIntValidator(5, 60))
        self.lineEdit_3.setText(self.cs.acq_wait)

        # Time Between Images
        '''
        Time Between Images/Binning 
        '''
        # Binning:

        self.selfLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.lineEdit_3)
        self.label_5 = QtWidgets.QLabel(self.selfLayoutWidget)
        self.label_5.setObjectName("label_5")
        self.selfLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.label_5)

        self.comboBox_2 = QtWidgets.QComboBox(self.selfLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.comboBox_2.sizePolicy().hasHeightForWidth())
        self.comboBox_2.setSizePolicy(sizePolicy)
        self.comboBox_2.setCurrentText("")
        self.comboBox_2.setMinimumContentsLength(0)
        self.comboBox_2.setObjectName("comboBox_2")

        self.comboBox_2.addItems([self.tr("1x1"), self.tr("2x2"), self.tr("4x4")])
        self.comboBox_2.setCurrentIndex(int(self.cs.binning))

        # Binning
        '''
        Binning/Exposure Time
        '''
        # Exposure Time:

        self.selfLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.comboBox_2)
        self.label_6 = QtWidgets.QLabel(self.selfLayoutWidget)
        self.label_6.setObjectName("label_6")
        self.selfLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.label_6)

        self.lineEdit_4 = QtWidgets.QLineEdit(self.selfLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_4.sizePolicy().hasHeightForWidth())
        self.lineEdit_4.setSizePolicy(sizePolicy)
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.lineEdit_4.setValidator(QtGui.QIntValidator(5, 60))
        self.lineEdit_4.setText(self.cs.exp)

        # Exposure Time
        '''
        Exposure Time/Images Path
        '''
        # Images Path:

        self.selfLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.lineEdit_4)
        self.label_7 = QtWidgets.QLabel(self.selfLayoutWidget)
        self.label_7.setObjectName("label_7")
        self.selfLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.label_7)

        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.lineEdit_5 = QtWidgets.QLineEdit(self.selfLayoutWidget)
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.lineEdit_5.setText(self.cs.path)
        self.lineEdit_5.setReadOnly(True)
        self.horizontalLayout.addWidget(self.lineEdit_5)

        self.toolButton = QtWidgets.QToolButton(self.selfLayoutWidget)
        self.toolButton.setObjectName("toolButton")
        self.horizontalLayout.addWidget(self.toolButton)
        self.toolButton.clicked.connect(self.get_dir)

        self.selfLayout.setLayout(6, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout)

        # Images Path
        '''
        Images Path/Buttons
        '''
        # Buttons:

        self.buttonBox = QtWidgets.QDialogButtonBox(self.selfLayoutWidget)
        self.buttonBox.addButton("Defaults", QtWidgets.QDialogButtonBox.RejectRole)
        self.buttonBox.addButton("Save", QtWidgets.QDialogButtonBox.AcceptRole)
        self.buttonBox.setCenterButtons(True)
        self.buttonBox.setObjectName("buttonBox")
        # self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setText("Save")
        # self.buttonBox.button(QtWidgets.QDialogButtonBox.RejectRole).setText("Defaults")
        self.selfLayout.setWidget(7, QtWidgets.QFormLayout.SpanningRole, self.buttonBox)
        # self.buttonBox.clicked(QAbstractButton=QtWidgets.QDialogButtonBox.Save).connect(self.save_settings)
        self.buttonBox.accepted.connect(self.save_settings)
        self.buttonBox.rejected.connect(self.defaults)
        # self.buttonBox.clicked(QAbstractButton=QtWidgets.QDialogButtonBox.RestoreDefaults).connect(self.defaults)

        self.retranslate_ui()
        QtCore.QMetaObject.connectSlotsByName(self)
        
        self.show()
예제 #8
0
 def setUp(self):
     self.actions=Actions()
     SQL="update account_fund set balance='10000',frozen_amount='0',daily_balance='0',daily_frozen_amount='0' where account_id='105372'"
     self.actions.conn(SQL)
예제 #9
0
    def setup_ui(self):

        self.settings = UiSelf()
        self.actionsMenu = Actions()
        # self.actionsMenu.signal_console.connect(self.write_to_console)
        self.console = ConsoleThreadOutput()

        self.setObjectName("self")
        self.setFixedSize(500, 268)

        size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                            QtWidgets.QSizePolicy.Fixed)
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(0)
        size_policy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())

        self.setSizePolicy(size_policy)
        self.setWindowTitle("CCD Controller 3.0.0 (Pixis)")

        self.centralwidget = QtWidgets.QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")

        self.plainTextEdit = QtWidgets.QPlainTextEdit(self.centralwidget)
        self.plainTextEdit.setEnabled(True)

        font = QtGui.QFont()
        if os.name == "nt":
            font.setFamily("Terminal")
            font.setPointSize(11)
        else:
            font.setFamily("Noto")
            font.setPointSize(11)

        self.plainTextEdit.setFont(font)
        self.plainTextEdit.viewport().setProperty(
            "cursor", QtGui.QCursor(QtCore.Qt.ArrowCursor))
        self.plainTextEdit.setFocusPolicy(QtCore.Qt.NoFocus)
        self.plainTextEdit.setToolTip("")
        self.plainTextEdit.setStatusTip("")
        self.plainTextEdit.setWhatsThis("")
        self.plainTextEdit.setAccessibleName("")
        self.plainTextEdit.setAccessibleDescription("")
        # color: rgb(0, 255, 0)
        self.plainTextEdit.setStyleSheet(
            "color: green; background-color: rgb(0, 0, 0);")
        self.plainTextEdit.setPlainText("")
        self.plainTextEdit.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
        self.plainTextEdit.setObjectName("plainTextEdit")
        self.console.set_console(self.plainTextEdit)

        self.verticalLayout.addWidget(self.plainTextEdit)
        self.setCentralWidget(self.centralwidget)
        self.toolBar = QtWidgets.QToolBar(self)
        self.toolBar.setMovable(False)
        self.toolBar.setIconSize(QtCore.QSize(48, 48))
        self.toolBar.setObjectName("toolBar")
        self.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)

        if os.name == "nt":
            dir_orientation = os.getcwd() + "\\ui\\icons\\"
        else:
            dir_orientation = os.getcwd() + "/ui/icons/"

        self.actionConnect = QtWidgets.QAction(self)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(dir_orientation + "Connect.png"),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionConnect.setIcon(icon)
        self.actionConnect.setObjectName("actionConnect")
        self.actionConnect.triggered.connect(self.actionsMenu.connect)

        self.actionDisconnect = QtWidgets.QAction(self)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(dir_orientation + "Disconnect.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionDisconnect.setIcon(icon1)
        self.actionDisconnect.setObjectName("actionDisconnect")
        self.actionDisconnect.triggered.connect(
            self.actionsMenu.disconnect_cam)

        self.actionRun = QtWidgets.QAction(self)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(dir_orientation + "Run_Manual.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionRun.setIcon(icon2)
        self.actionRun.setObjectName("actionRun")
        self.actionRun.triggered.connect(self.actionsMenu.shoot)

        self.actionStop = QtWidgets.QAction(self)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(dir_orientation + "Stop.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionStop.setIcon(icon3)
        self.actionStop.setObjectName("actionStop")
        self.actionStop.triggered.connect(self.actionsMenu.stop)

        self.actionSettings = QtWidgets.QAction(self)
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap(dir_orientation + "Settings.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionSettings.setIcon(icon4)
        self.actionSettings.setObjectName("actionSettings")
        self.actionSettings.triggered.connect(self.open_settings)

        self.actionExit = QtWidgets.QAction(self)
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap(dir_orientation + "Exit.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionExit.setIcon(icon5)
        self.actionExit.setObjectName("actionExit")
        self.actionExit.triggered.connect(self.close)

        self.actionPicFolder = QtWidgets.QAction(self)
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap(dir_orientation + "Folder.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionPicFolder.setIcon(icon6)
        self.actionPicFolder.setObjectName("actionPicFolder")
        self.actionPicFolder.triggered.connect(self.pics_folder)

        self.actionGetTemp = QtWidgets.QAction(self)
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap(dir_orientation + "Temp.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionGetTemp.setIcon(icon7)
        self.actionGetTemp.setObjectName("actionGetTemp")
        self.actionGetTemp.triggered.connect(self.show_temp)

        self.toolBar.addAction(self.actionConnect)
        self.toolBar.addAction(self.actionDisconnect)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.actionRun)
        self.toolBar.addAction(self.actionStop)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.actionSettings)
        self.toolBar.addAction(self.actionExit)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.actionPicFolder)
        self.toolBar.addAction(self.actionGetTemp)
        self.toolBar.addSeparator()

        self.retranslate_ui()
        QtCore.QMetaObject.connectSlotsByName(self)

        self.show()
예제 #10
0
from flask import Flask, request, send_file, render_template, abort, Response, redirect
from rq import Queue
from rq.job import Job
from flask_cors import CORS
from rq_scheduler import Scheduler
from redis import Redis

from utils.config import Configs
from packages.github.github import Github
from worker import conn
from actions.actions import Actions
from mongo.db import *

configs = Configs()
actions = Actions()
github = Github()
DB()

app = Flask(__name__, static_folder="./dist/static", template_folder="./dist")

CORS(app, resources={r"/*": {"origins": "*"}})

q = Queue(connection=conn)
scheduler = Scheduler(connection=Redis())


@app.after_request
def set_response_headers(response):
    response.headers["Cache-Control"] = "no-cache"
    response.headers["Pragma"] = "no-cache"