Ejemplo n.º 1
0
    def handle_controller_event(self, connection, controller_id, event_type,
                                event_args):

        if event_type == 'session_started':
            pass

        if event_type == 'session_ended':
            # Clear notes on screen since they would have been cleared in sensor controller.
            self.view.clear_session_notes(controller_id)

        if event_type == 'new_active_issue':
            issue_info = event_args
            self.current_issues.append(Issue(**issue_info))
            # TODO support multiple controllers
            if self.local_controller['session_active']:
                self.view.notify_new_issue(issue_info)
            self.view.refresh_current_issues(self.current_issues)

        if event_type == 'issue_resolved':
            issue_info = event_args
            for issue in self.current_issues[:]:
                if not issue.resolved and issue.matches(issue_info):
                    issue.resolved = True
                    issue.expiration_time = issue_info['end_time']

                    if issue.acked:
                        self.current_issues.remove(issue)
                        self.old_issues.append(issue)
            self.view.refresh_current_issues(self.current_issues)

        if event_type == 'issue_changed':
            issue_info = event_args
            for issue in self.current_issues:
                if not issue.resolved and issue.matches(issue_info):
                    issue.level = issue_info['level']
                    issue.reason = issue_info['reason']
            self.view.refresh_current_issues(self.current_issues)

        if event_type in ['extra_setting_added', 'extra_setting_removed']:
            self.view.extra_setting_added_or_removed(
                updated_extra_settings=event_args)

        if event_type == 'controller_crashed':

            message = "Oh no! Part of the program has crashed. If you had a session active don't worry it will be saved when the program closes.\n" \
                      "Please report the problem on the github issue tracker. To get a traceback of the problem " \
                      "check either the most recent debug log (located at ~/dysense_debug_logs/) or the session log if you had a session active."
            self.view.show_user_message(message, logging.CRITICAL)
            # This will cause app.exec_() to return.
            QCoreApplication.exit(1)

        if event_type == 'manager_crashed':
            # TODO This isn't really a controller event
            message = "Oh no! Part of the program has crashed. If you had a session active don't worry it will be saved when the program closes.\n" \
                      "Please report this error on the github issue tracker.\nPress Ctrl+C to copy text from this dialog."
            for line in event_args:
                message += '\n' + line
            self.view.show_user_message(message, logging.CRITICAL)
            # This will cause app.exec_() to return.
            QCoreApplication.exit(1)
class Receiver(QObject):
    def __init__(self):
        super().__init__()
        self.utt = ""
        self.app = QCoreApplication(sys.argv)

        self.a = AsrFacility()
        self.a.addReceiver(self.callback)
        self.a.requestUtteranceAsync()

    @pyqtSlot(str)
    def callback(self, utt):
        print("*** Recognized text:", utt)
        self.utt = utt
        self.app.exit()
Ejemplo n.º 3
0
    def closeEvent(self, event):
        if not ProcessManager.hasActiveProcess:
            self.saveSettings()
            QCoreApplication.exit()
            return

        ret = self.showOkCancelMessageBox("Are you sure do you want to quit?",
                                          "Exit confirmation")
        if ret == QMessageBox.Cancel:
            event.ignore()
            return

        self.saveSettings()
        ProcessManager.killemall()
        event.accept()
        QCoreApplication.exit()
Ejemplo n.º 4
0
    def closeEvent(self, event):
        if not ProcessManager.hasActiveProcess:
            self.saveSettings()
            QCoreApplication.exit()
            return

        ret = self.showOkCancelMessageBox("Are you sure do you want to quit?",
                                          "Exit confirmation")
        if ret == QMessageBox.Cancel:
            event.ignore()
            return

        self.saveSettings()
        ProcessManager.killemall()
        event.accept()
        QCoreApplication.exit()
Ejemplo n.º 5
0
    def closeEvent(self, event):
        if not ProcessManager.hasActiveProcess:
            self.saveSettings()
            QCoreApplication.exit()
            return

        msgBox = QMessageBox(self, text="Are you sure do you want to quit?")
        msgBox.setWindowTitle("Exit confirmation")
        msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
        ret = msgBox.exec_()
        if ret == QMessageBox.Cancel:
            event.ignore()
            return

        self.saveSettings()
        ProcessManager.killemall()
        event.accept()
        QCoreApplication.exit()
Ejemplo n.º 6
0
    
        for record in data['tipodecambioni']:
            if not query.prepare( """
    	    INSERT INTO tiposcambio (tasa, fecha) VALUES ( :tasa, :fecha)
    	    """ ):
                raise Exception( "No se pudo preparar la consulta" )
            query.bindValue( ":tasa", record['cambio']['valor'] )
            query.bindValue( ":fecha", record['cambio']['fecha'] )
            print "*************************"
            print record['cambio']['valor']
            print record['cambio']['fecha']
            print "*************************"
            if not query.exec_():
                raise Exception( "No se pudo ejecutar la consulta" )
    
        if not db.commit():
            raise Exception( "No se pudo completar la transaccion" )

    except Exception as inst:
        db.rollback()
        print query.lastError().text()
        print unicode(inst)
    finally:
        if db.isOpen():
            db.close()

    app.exit()



Ejemplo n.º 7
0
 def _coldShutdown(self, exitCode=0):
     # before exiting, process remaining events (e.g., pending messages like HELO_LEAVE)
     QCoreApplication.processEvents()
     QCoreApplication.exit(exitCode)
     self._shuttingDown = True
Ejemplo n.º 8
0
        if not db.transaction():
            raise Exception(u"No se pudo iniciar la transacción")

        for record in data['tipodecambioni']:
            if not query.prepare("""
    	    INSERT INTO tiposcambio (tasa, fecha) VALUES ( :tasa, :fecha)
    	    """):
                raise Exception("No se pudo preparar la consulta")
            query.bindValue(":tasa", record['cambio']['valor'])
            query.bindValue(":fecha", record['cambio']['fecha'])
            print "*************************"
            print record['cambio']['valor']
            print record['cambio']['fecha']
            print "*************************"
            if not query.exec_():
                raise Exception("No se pudo ejecutar la consulta")

        if not db.commit():
            raise Exception("No se pudo completar la transaccion")

    except Exception as inst:
        db.rollback()
        print query.lastError().text()
        print unicode(inst)
    finally:
        if db.isOpen():
            db.close()

    app.exit()
Ejemplo n.º 9
0
 def reject(self):
     QDialog.reject(self)
     QCoreApplication.exit(1)