Beispiel #1
0
class Lucidity:
    def __init__(self):
        logger.info("Lucidity initialized. Hello there!")
        self.mainDelegate = MainDelegate()
        self.mainDelegate.mainApp = self
        self.sequence = Sequence()
        self.settings = Settings(PathFinder.findUserFile('settings.db'))
        self.mediaRequestLoop = MediaRequestLoop(PathFinder.findUserFile('media.db'))
        self.midiEventLoop = MidiEventLoop(self.mainDelegate)
        self.statusLoop = StatusLoop()
        self.systemUsageLoop = SystemUsageLoop()
        self.mainWindow = None

    def run(self):
        try:
            self.mainWindow = MainWindow(self.mainDelegate, self.sequence, self.settings,
                                         self.mediaRequestLoop, self.midiEventLoop,
                                         self.statusLoop, self.systemUsageLoop)
            self.mainWindow.open()
            self.mainWindow.setStatusText("Starting Up...")
            initializer = Initializer(self)
            initializer.start()
            self.mainWindow.run()
        except BaseException:
            logger.error(traceback.format_exc().strip())
            try:
                self.quit()
            except BaseException as error:
                logger.error("Unable to shut down cleanly: " + str(error))
                exit()

    def quit(self):
        logger.info("Lucidity is quitting. Bye-bye!")
        self.mainWindow.setStatusText("Shutting Down...")
        if self.statusLoop.is_alive():
            self.statusLoop.quit()
            self.statusLoop.join()
        if self.systemUsageLoop.is_alive():
            self.systemUsageLoop.quit()
            self.systemUsageLoop.join()
        if self.mediaRequestLoop.is_alive():
            self.mediaRequestLoop.quit()
            self.mediaRequestLoop.join()
        if self.midiEventLoop.is_alive():
            self.midiEventLoop.quit()
            self.midiEventLoop.join()
        self.mainWindow.quit()
Beispiel #2
0
 def run(self):
     try:
         self.mainWindow = MainWindow(self.mainDelegate, self.sequence, self.settings,
                                      self.mediaRequestLoop, self.midiEventLoop,
                                      self.statusLoop, self.systemUsageLoop)
         self.mainWindow.open()
         self.mainWindow.setStatusText("Starting Up...")
         initializer = Initializer(self)
         initializer.start()
         self.mainWindow.run()
     except BaseException:
         logger.error(traceback.format_exc().strip())
         try:
             self.quit()
         except BaseException as error:
             logger.error("Unable to shut down cleanly: " + str(error))
             exit()