Пример #1
0
 def createConfiguration(self, hostUri, username, password, configurationPath, dataPath):
     """ Delegates the call to the model. """
     
     self.__errorMessage = None
     self.__view.createPushButton.setEnabled(False)
     thread = threading.Thread(target=self.__prepare, args=(hostUri, configurationPath, dataPath, username, password))
     thread.start()
     while thread.isAlive():
         qApp.processEvents()
     self.__view.createPushButton.setEnabled(True)
     
     if not self.__errorMessage is None:
         self._logger.error(self.__errorMessage)
         self.__view.showErrorMessage(self.__errorMessage)
     else:
         createConfiguration = True
         if self.__model.exists:
             createConfiguration = self.__view.showQuestion("The configuration path does already exist. Overwrite it?")
         self.__view.createPushButton.setEnabled(False)
         thread = threading.Thread(target=self.__performConfigurationCreation, args=(createConfiguration, ))
         thread.start()
         while thread.isAlive():
             qApp.processEvents()
         if not self.__errorMessage is None:
             self._logger.error(self.__errorMessage)
             self.__view.showErrorMessage(self.__errorMessage)
         self.__view.createPushButton.setEnabled(True)
Пример #2
0
    def syncMoveRelative(self, position):
        old_pos = self.positionValue
        self.positionValue = old_pos + position
        self.positionChan.setValue( self.convertValue(self.positionValue) )

        while self.stateValue == "RUNNING" or self.stateValue == "MOVING":
            qApp.processEvents(100)
Пример #3
0
    def createConfiguration(self, hostUri, username, password,
                            configurationPath, dataPath):
        """ Delegates the call to the model. """

        self.__errorMessage = None
        self.__view.createPushButton.setEnabled(False)
        thread = threading.Thread(target=self.__prepare,
                                  args=(hostUri, configurationPath, dataPath,
                                        username, password))
        thread.start()
        while thread.isAlive():
            qApp.processEvents()
        self.__view.createPushButton.setEnabled(True)

        if not self.__errorMessage is None:
            self._logger.error(self.__errorMessage)
            self.__view.showErrorMessage(self.__errorMessage)
        else:
            createConfiguration = True
            if self.__model.exists:
                createConfiguration = self.__view.showQuestion(
                    "The configuration path does already exist. Overwrite it?")
            self.__view.createPushButton.setEnabled(False)
            thread = threading.Thread(
                target=self.__performConfigurationCreation,
                args=(createConfiguration, ))
            thread.start()
            while thread.isAlive():
                qApp.processEvents()
            if not self.__errorMessage is None:
                self._logger.error(self.__errorMessage)
                self.__view.showErrorMessage(self.__errorMessage)
            self.__view.createPushButton.setEnabled(True)
Пример #4
0
def main():
    if not os.path.exists(os.path.expanduser("~/.pyqlogger")):
        os.mkdir(os.path.expanduser("~/.pyqlogger"))
    settings = Settings.Settings.load()
    UI.prepareModule(settings)
    app = UI.API.KQApplication(sys.argv, None)
    stat = UI.API.prepareCommandLine()
    pic = QPixmap(150, 50)
    pic.fill()
    loginsplash = QSplashScreen(pic)
    pixmap = QPixmap("splash.png")
    splash = QSplashScreen(pixmap)
    splash.show()
    splash.message("Loading forms...", alignflag)
    qApp.processEvents()
    load_forms(splash, app, settings)
    splash.message("Loading plugins...", alignflag)
    qApp.processEvents()
    manager = Manager.load(__FORMS__["Main"]["Impl"])
    del splash
    acc = None
    pwd = None
    if settings.AutoLogin:  # check if we have auto login info
        acc = settings.accountByName(settings.AutoLogin)
        pwd = acc.Password

    while True:
        if not acc:
            wnd = __FORMS__["Login"]
            if wnd["Impl"].init(settings, __FORMS__, manager):
                if wnd["Class"].exec_loop() == QDialog.Accepted:
                    acc = wnd["Impl"].acc
                    pwd = str(wnd["Impl"].edtPassword.text())
        if not acc or not pwd:
            break
        else:
            (acc.Password, oldpwd) = (pwd, acc.Password)
            acc.init()
            loginsplash.show()
            loginsplash.message("Logging in...", Qt.AlignCenter)
            logres = acc.login()
            loginsplash.hide()
            acc.Password = oldpwd
            if not logres:
                QMessageBox.warning(None, "Failed!", """Cannot login!""")
                acc = None
            else:
                wnd = __FORMS__["Main"]
                acc.init()
                wnd["Impl"].init(settings,__FORMS__, acc, pwd,\
                                 manager)
                app.setMainWidget(wnd["Class"])
                wnd["Class"].show()
                #splash.finish(wnd["Class"])
                app.exec_loop()
                if wnd["Impl"].reload:
                    acc = None
                else:
                    break
Пример #5
0
def main():
    if not os.path.exists(os.path.expanduser("~/.pyqlogger")):
        os.mkdir(os.path.expanduser("~/.pyqlogger"))    
    settings = Settings.Settings.load()
    UI.prepareModule(settings)
    app =  UI.API.KQApplication(sys.argv, None)
    stat = UI.API.prepareCommandLine()    
    pic = QPixmap ( 150, 50)
    pic.fill()
    loginsplash = QSplashScreen( pic )
    pixmap = QPixmap( "splash.png" )
    splash = QSplashScreen( pixmap )
    splash.show()
    splash.message( "Loading forms...",alignflag )
    qApp.processEvents()
    load_forms(splash,app,settings)
    splash.message( "Loading plugins...",alignflag )
    qApp.processEvents()
    manager = Manager.load(__FORMS__["Main"]["Impl"])
    del splash
    acc = None
    pwd = None
    if settings.AutoLogin: # check if we have auto login info
        acc = settings.accountByName(settings.AutoLogin)
        pwd = acc.Password

    while True:
        if not acc:
            wnd = __FORMS__["Login"]
            if wnd["Impl"].init(settings,__FORMS__,manager):
                if wnd["Class"].exec_loop() == QDialog.Accepted:
                    acc = wnd["Impl"].acc
                    pwd = str(wnd["Impl"].edtPassword.text())
        if not acc or not pwd:
            break
        else:
            (acc.Password,oldpwd) = (pwd,acc.Password)            
            acc.init()
            loginsplash.show()
            loginsplash.message( "Logging in...",Qt.AlignCenter)            
            logres = acc.login()
            loginsplash.hide()
            acc.Password = oldpwd
            if not logres:
                QMessageBox.warning(None,"Failed!","""Cannot login!""")
                acc = None
            else:
                wnd = __FORMS__["Main"]
                acc.init()
                wnd["Impl"].init(settings,__FORMS__, acc, pwd,\
                                 manager)
                app.setMainWidget(wnd["Class"])
                wnd["Class"].show()
                #splash.finish(wnd["Class"])
                app.exec_loop()
                if wnd["Impl"].reload:
                    acc = None
                else:
                    break
Пример #6
0
 def syncMove(self, position):
     prev_position = self.getPosition()
     #self.positionValue = position
     relative_position = position - prev_position
     self.syncMoveRelative(relative_position)
     time.sleep(0.2)  # allow MD2 to change the state
     while self.stateValue == "RUNNING" or self.stateValue == "MOVING":  # or self.stateValue == SpecMotor.MOVESTARTED:
         qApp.processEvents(100)
Пример #7
0
    def moveRelative(self, position):
        old_pos = self.positionValue
        self.positionValue = old_pos + position
        self.positionChan.setValue( self.convertValue(self.positionValue) )
        logging.info("TangoDCMotor: movingRelative. motor will go to %s " % str(self.positionValue))

        while self.stateValue == "RUNNING" or self.stateValue == "MOVING":
            qApp.processEvents(100)
Пример #8
0
 def syncMove(self, position):
     prev_position      = self.getPosition()
     #self.positionValue = position
     relative_position = position - prev_position
     self.syncMoveRelative(relative_position)
     time.sleep(0.2) # allow MD2 to change the state
     while self.stateValue == "RUNNING" or self.stateValue == "MOVING": # or self.stateValue == SpecMotor.MOVESTARTED:
         qApp.processEvents(100)
Пример #9
0
    def moveRelative(self, position):
        old_pos = self.positionValue
        self.positionValue = old_pos + position
        self.positionChan.setValue(self.convertValue(self.positionValue))
        logging.info("TangoDCMotor: movingRelative. motor will go to %s " %
                     str(self.positionValue))

        while self.stateValue == "RUNNING" or self.stateValue == "MOVING":
            qApp.processEvents(100)
Пример #10
0
 def wagoIn(self):
     if str(self.beamstopState.getValue()) == 'INSERT':
         logging.getLogger("HWR").info('TangoLightPX1. Extracting BeamStop.')
         self.beamstop_out()
         while str(self.beamstopState.getValue()) != "EXTRACT":
             qApp.processEvents()
     detposition = self.detdistchan.getValue()
     logging.getLogger("HWR").info('TangoLightPX1. DetDist= %.2f mm. OK.' % detposition)
     if detposition < self.min_detector_distance:
         m1 = "Can't insert Light-arm, detector distance too close: %.1f mm. " % detposition
         m2 = "You need to set the distance to > %.1f mm." % self.min_detector_distance
         logging.getLogger("user_level_log").error("%s: " + m1+m2, self.name())
     else:
         logging.getLogger("HWR").info('TangoLightPX1. Inserting Light.')       
         self.setIn()
Пример #11
0
    def syncMoveRelative(self, position):
        old_pos = self.positionValue
        self.positionValue = old_pos + position
        logging.info("TangoDCMotor: syncMoveRelative going to %s " % str( self.convertValue(self.positionValue)))
        self.positionChan.setValue( self.convertValue(self.positionValue) )

        dev = DeviceProxy(self.tangoname)
        time.sleep(0.2) # allow MD2 to change the state

        mystate = str( dev.State() )
        logging.info("TangoDCMotor: %s syncMoveRelative state is %s / %s " % ( self.tangoname, str( self.stateValue ), mystate))

        while mystate == "RUNNING" or mystate == "MOVING":
            logging.info("TangoDCMotor: syncMoveRelative is moving %s" % str( mystate ))
            time.sleep(0.1)
            mystate = str( dev.State() )
            qApp.processEvents(100)
Пример #12
0
 def wagoIn(self):
     if str(self.beamstopState.getValue()) == 'INSERT':
         logging.getLogger("HWR").info(
             'TangoLightPX1. Extracting BeamStop.')
         self.beamstop_out()
         while str(self.beamstopState.getValue()) != "EXTRACT":
             qApp.processEvents()
     detposition = self.detdistchan.getValue()
     logging.getLogger("HWR").info('TangoLightPX1. DetDist= %.2f mm. OK.' %
                                   detposition)
     if detposition < self.min_detector_distance:
         m1 = "Can't insert Light-arm, detector distance too close: %.1f mm. " % detposition
         m2 = "You need to set the distance to > %.1f mm." % self.min_detector_distance
         logging.getLogger("user_level_log").error("%s: " + m1 + m2,
                                                   self.name())
     else:
         logging.getLogger("HWR").info('TangoLightPX1. Inserting Light.')
         self.setIn()
Пример #13
0
    def fr(self):
        from qt import qApp
        if self.visualize == None:  #grafa se ni
            return

        if not self.frButton.isOn():
            self.stopOptimization = 1
            self.frButton.setOn(0)
            self.frButton.setText("Fruchterman Reingold")
            return

        self.frButton.setText("Stop")
        qApp.processEvents()
        self.stopOptimization = 0
        tolerance = 5
        initTemp = 1000
        breakpoints = 6
        k = int(self.frSteps / breakpoints)
        o = self.frSteps % breakpoints
        iteration = 0
        coolFactor = exp(log(10.0 / 10000.0) / self.frSteps)

        if k > 0:
            while iteration < breakpoints:
                #print "iteration, initTemp: " + str(initTemp)
                if self.stopOptimization:
                    return
                initTemp = self.visualize.fruchtermanReingold(
                    k, initTemp, coolFactor, self.graph.hiddenNodes)
                iteration += 1
                qApp.processEvents()
                self.updateCanvas()

            #print "ostanek: " + str(o) + ", initTemp: " + str(initTemp)
            if self.stopOptimization:
                return
            initTemp = self.visualize.fruchtermanReingold(
                o, initTemp, coolFactor, self.graph.hiddenNodes)
            qApp.processEvents()
            self.updateCanvas()
        else:
            while iteration < o:
                #print "iteration ostanek, initTemp: " + str(initTemp)
                if self.stopOptimization:
                    return
                initTemp = self.visualize.fruchtermanReingold(
                    1, initTemp, coolFactor, self.graph.hiddenNodes)
                iteration += 1
                qApp.processEvents()
                self.updateCanvas()

        self.frButton.setOn(0)
        self.frButton.setText("Fruchterman Reingold")
Пример #14
0
    def syncMoveRelative(self, position):
        old_pos = self.positionValue
        self.positionValue = old_pos + position
        logging.info("TangoDCMotor: syncMoveRelative going to %s " %
                     str(self.convertValue(self.positionValue)))
        self.positionChan.setValue(self.convertValue(self.positionValue))

        dev = DeviceProxy(self.tangoname)
        time.sleep(0.2)  # allow MD2 to change the state

        mystate = str(dev.State())
        logging.info("TangoDCMotor: %s syncMoveRelative state is %s / %s " %
                     (self.tangoname, str(self.stateValue), mystate))

        while mystate == "RUNNING" or mystate == "MOVING":
            logging.info("TangoDCMotor: syncMoveRelative is moving %s" %
                         str(mystate))
            time.sleep(0.1)
            mystate = str(dev.State())
            qApp.processEvents(100)
    def fr(self):
        from qt import qApp

        if self.visualize == None:  # grafa se ni
            return

        if not self.frButton.isOn():
            self.stopOptimization = 1
            self.frButton.setOn(0)
            self.frButton.setText("Fruchterman Reingold")
            return

        self.frButton.setText("Stop")
        qApp.processEvents()
        self.stopOptimization = 0
        tolerance = 5
        initTemp = 1000
        breakpoints = 6
        k = int(self.frSteps / breakpoints)
        o = self.frSteps % breakpoints
        iteration = 0
        coolFactor = exp(log(10.0 / 10000.0) / self.frSteps)

        if k > 0:
            while iteration < breakpoints:
                # print "iteration, initTemp: " + str(initTemp)
                if self.stopOptimization:
                    return
                initTemp = self.visualize.fruchtermanReingold(k, initTemp, coolFactor, self.graph.hiddenNodes)
                iteration += 1
                qApp.processEvents()
                self.updateCanvas()

            # print "ostanek: " + str(o) + ", initTemp: " + str(initTemp)
            if self.stopOptimization:
                return
            initTemp = self.visualize.fruchtermanReingold(o, initTemp, coolFactor, self.graph.hiddenNodes)
            qApp.processEvents()
            self.updateCanvas()
        else:
            while iteration < o:
                # print "iteration ostanek, initTemp: " + str(initTemp)
                if self.stopOptimization:
                    return
                initTemp = self.visualize.fruchtermanReingold(1, initTemp, coolFactor, self.graph.hiddenNodes)
                iteration += 1
                qApp.processEvents()
                self.updateCanvas()

        self.frButton.setOn(0)
        self.frButton.setText("Fruchterman Reingold")
Пример #16
0
def load_forms(splash, app, settings):
    splash.message( "Loading form: Main",alignflag )
    qApp.processEvents()
    from PyQLogger.Dialogs import MainDialog
    wnd = MainDialog.MainDialog()
    wnd_c = qt_ui_loader.create( 'UI/maindialog.ui', wnd,None,True )
    wnd_c.closeEvent = wnd.closeEvent
    __FORMS__["Main"] = { "Class": wnd_c , "Impl": wnd }
    wnd.init_ui(settings, __FORMS__)
    UI.API.setupTray(app, __FORMS__["Main"])
    UI.API.setupDCOP(app, __FORMS__["Main"])
    splash.message( "Loading form: Login" ,alignflag)
    qApp.processEvents()
    from PyQLogger.Dialogs import LoginDialog
    wnd = LoginDialog.LoginDialog()
    wnd_c = qt_ui_loader.create( 'UI/logindialog.ui', wnd,None,True )
    __FORMS__["Login"] = { "Class": wnd_c , "Impl": wnd }
    splash.message( "Loading form: Settings",alignflag )
    qApp.processEvents()
    from PyQLogger.Dialogs import SettingsDialog
    wnd = SettingsDialog.SettingsDialog()
    wnd_c = qt_ui_loader.create( 'UI/settingsdialog.ui', wnd,None,True )
    __FORMS__["Settings"] = { "Class": wnd_c , "Impl": wnd }
    splash.message( "Loading form: Account Settings",alignflag )
    qApp.processEvents()
    from PyQLogger.Dialogs import AccountSettingsDialog
    wnd = AccountSettingsDialog.AccountSettingsDialog()
    wnd_c = qt_ui_loader.create( 'UI/accountsettingsdialog.ui', wnd,None,True )
    wnd.init_ui()
    __FORMS__["AccountSettings"] = { "Class": wnd_c , "Impl": wnd }
    splash.message( "Loading form: Image Insert",alignflag )
    qApp.processEvents()
    from PyQLogger.Dialogs import ImageDialog
    wnd = ImageDialog.ImageDialog()
    wnd_c = qt_ui_loader.create( 'UI/imagedialog.ui', wnd,None,True )
    __FORMS__["Image"] = { "Class": wnd_c , "Impl": wnd }
    splash.message( "Loading form: Url Insert",alignflag )
    qApp.processEvents()
    from PyQLogger.Dialogs import UrlDialog
    wnd = UrlDialog.UrlDialog()
    wnd_c = qt_ui_loader.create( 'UI/urldialog.ui', wnd,None,True )
    __FORMS__["Url"] = { "Class": wnd_c , "Impl": wnd }
    splash.message( "Loading form: Plugin settings",alignflag )
    qApp.processEvents();
    from PyQLogger.Dialogs import PluginSettingsDialog
    wnd = PluginSettingsDialog.PluginSettingsDialog()
    wnd_c = qt_ui_loader.create( 'UI/pluginsettingsdialog.ui', wnd,None,True )
    __FORMS__["PluginSettings"] = { "Class": wnd_c , "Impl": wnd }
    splash.message( "Loading form: Template settings",alignflag )
    qApp.processEvents()
    wnd = QDialog()
    wnd_c = qt_ui_loader.create( 'UI/templatesettingsdialog.ui', wnd, None,True )
    __FORMS__["TemplateSettings"] = { "Class": wnd_c , "Impl": wnd }
Пример #17
0
def load_forms(splash, app, settings):
    splash.message("Loading form: Main", alignflag)
    qApp.processEvents()
    from PyQLogger.Dialogs import MainDialog
    wnd = MainDialog.MainDialog()
    wnd_c = qt_ui_loader.create('UI/maindialog.ui', wnd, None, True)
    wnd_c.closeEvent = wnd.closeEvent
    __FORMS__["Main"] = {"Class": wnd_c, "Impl": wnd}
    wnd.init_ui(settings, __FORMS__)
    UI.API.setupTray(app, __FORMS__["Main"])
    UI.API.setupDCOP(app, __FORMS__["Main"])
    splash.message("Loading form: Login", alignflag)
    qApp.processEvents()
    from PyQLogger.Dialogs import LoginDialog
    wnd = LoginDialog.LoginDialog()
    wnd_c = qt_ui_loader.create('UI/logindialog.ui', wnd, None, True)
    __FORMS__["Login"] = {"Class": wnd_c, "Impl": wnd}
    splash.message("Loading form: Settings", alignflag)
    qApp.processEvents()
    from PyQLogger.Dialogs import SettingsDialog
    wnd = SettingsDialog.SettingsDialog()
    wnd_c = qt_ui_loader.create('UI/settingsdialog.ui', wnd, None, True)
    __FORMS__["Settings"] = {"Class": wnd_c, "Impl": wnd}
    splash.message("Loading form: Account Settings", alignflag)
    qApp.processEvents()
    from PyQLogger.Dialogs import AccountSettingsDialog
    wnd = AccountSettingsDialog.AccountSettingsDialog()
    wnd_c = qt_ui_loader.create('UI/accountsettingsdialog.ui', wnd, None, True)
    wnd.init_ui()
    __FORMS__["AccountSettings"] = {"Class": wnd_c, "Impl": wnd}
    splash.message("Loading form: Image Insert", alignflag)
    qApp.processEvents()
    from PyQLogger.Dialogs import ImageDialog
    wnd = ImageDialog.ImageDialog()
    wnd_c = qt_ui_loader.create('UI/imagedialog.ui', wnd, None, True)
    __FORMS__["Image"] = {"Class": wnd_c, "Impl": wnd}
    splash.message("Loading form: Url Insert", alignflag)
    qApp.processEvents()
    from PyQLogger.Dialogs import UrlDialog
    wnd = UrlDialog.UrlDialog()
    wnd_c = qt_ui_loader.create('UI/urldialog.ui', wnd, None, True)
    __FORMS__["Url"] = {"Class": wnd_c, "Impl": wnd}
    splash.message("Loading form: Plugin settings", alignflag)
    qApp.processEvents()
    from PyQLogger.Dialogs import PluginSettingsDialog
    wnd = PluginSettingsDialog.PluginSettingsDialog()
    wnd_c = qt_ui_loader.create('UI/pluginsettingsdialog.ui', wnd, None, True)
    __FORMS__["PluginSettings"] = {"Class": wnd_c, "Impl": wnd}
    splash.message("Loading form: Template settings", alignflag)
    qApp.processEvents()
    wnd = QDialog()
    wnd_c = qt_ui_loader.create('UI/templatesettingsdialog.ui', wnd, None,
                                True)
    __FORMS__["TemplateSettings"] = {"Class": wnd_c, "Impl": wnd}
Пример #18
0
    def syncMove(self, position):
	prev_position      = self.getPosition()
	self.positionValue = position

	while self.stateValue == "RUNNING" or self.stateValue == "MOVING": # or self.stateValue == SpecMotor.MOVESTARTED:
	    qApp.processEvents(100)