Пример #1
0
    def installVersion(self):
        """
        installVersion updates mw4 with the standard pip package installer. this is
        actually only tested and ok for running in a virtual environment. updates have to run
        only once at a time, so a mutex ensures this. If everything is ok, a thread it
        started doing the install work and a callback is defined when finished.

        :return: True for test purpose
        """

        if not self.isVenv():
            self.app.message.emit('Not running in Virtual Environment', 2)
            return False

        if not self.mutexInstall.tryLock():
            self.app.message.emit('Install already running', 2)
            return False

        versionPackage = self.ui.versionAvailable.text()
        self.changeStyleDynamic(self.ui.installVersion, 'running', True)
        self.app.message.emit('Installing selected version ... please wait', 1)

        worker = tpool.Worker(self.runInstall, versionPackage=versionPackage)

        worker.signals.result.connect(self.installFinished)
        self.threadPool.start(worker)

        return True
Пример #2
0
def test_Worker_4(qtbot):
    def testFunc():
        return 'test'

    a = tpool.Worker(testFunc)

    with qtbot.assertNotEmitted(a.signals.error):
        a.run()
Пример #3
0
def test_Worker_3(qtbot):
    def testFunc():
        return 'test'

    a = tpool.Worker(testFunc)

    with qtbot.waitSignal(a.signals.result):
        a.run()
Пример #4
0
def test_Worker_2(qtbot):
    def testFunc():
        return 'test'

    a = tpool.Worker(testFunc)

    with qtbot.waitSignal(a.signals.finished):
        a.run()
Пример #5
0
def test_Worker_5(qtbot):
    def testFunc():
        raise Exception('Test')
        return 'test'

    a = tpool.Worker(testFunc)

    with qtbot.waitSignal(a.signals.error):
        a.run()
Пример #6
0
    def solveThreading(self,
                       fitsPath='',
                       raHint=None,
                       decHint=None,
                       scaleHint=None,
                       radius=2,
                       timeout=30,
                       updateFits=False):
        """
        solveThreading is the wrapper for doing the solve process in a threadpool
        environment of Qt. Otherwise the HMI would be stuck all the time during solving.
        it is done with an securing mutex to avoid starting solving twice. to solveClear
        is the partner of solve Threading

        :param fitsPath: full path to the fits image file to be solved
        :param raHint:  ra dest to look for solve in J2000
        :param decHint:  dec dest to look for solve in J2000
        :param scaleHint:  scale to look for solve in J2000
        :param radius:  search radius around target coordinates
        :param timeout: as said
        :param updateFits: flag, if the results should be written to the original file
        :return: success
        """

        if not self.solverSelected:
            return False
        if self.solverSelected not in self.solverEnviron:
            return False

        solverEnviron = self.solverEnviron[self.solverSelected]
        solver = solverEnviron['solver']

        if not os.path.isfile(fitsPath):
            self.signals.done.emit(solver.result)
            return False
        if not self.mutexSolve.tryLock():
            self.logger.info('overrun in solve threading')
            self.signals.done.emit(solver.result)
            return False

        self.signals.message.emit('solving')
        worker = tpool.Worker(
            solver.solve,
            solver=solverEnviron,
            fitsPath=fitsPath,
            raHint=raHint,
            decHint=decHint,
            scaleHint=scaleHint,
            radius=radius,
            timeout=timeout,
            updateFits=updateFits,
        )
        worker.signals.finished.connect(self.solveClear)
        self.threadPool.start(worker)

        return True
Пример #7
0
    def installVersion(self):
        """

        :return: success
        """

        if not self.isVenv():
            self.app.message.emit('Not running in Virtual Environment', 2)
            return False

        if not self.mutexInstall.tryLock():
            self.app.message.emit('Install already running', 2)
            return False

        versionPackage = self.ui.versionAvailable.text()
        self.changeStyleDynamic(self.ui.installVersion, 'running', True)
        self.app.message.emit('Installing selected version ... please wait', 1)

        worker = tpool.Worker(self.runInstall,
                              versionPackage=versionPackage)

        worker.signals.result.connect(self.installFinished)
        self.threadPool.start(worker)
Пример #8
0
def test_Worker_1():
    def testFunc():
        return 'test'

    a = tpool.Worker(testFunc)
    assert a.signals