def __init__(self, ostools = None, config = None): self.ostools = ostools if not self.ostools: self.ostools = OsTools() self.config = config if not self.config: self.config = Config() self._startLogging() self._loadConfig() self._startFileLogging() self.irReader = IrReader() self.processManager = ProcessManager()
def __set_up_helpers__(self): self.is_admin = True self.database_manager = DatabaseManager() self.logger = Logger() self.smart_home_activator = SmartHomeActivator() self.gesture_detector = GestureDetector() self.gesture_lexer = GestureLexer() self.gesture_parser = GestureParser() self.gesture_detected = None self.process_manager = ProcessManager() self.valid_webcam = None self.smart_home_activator.set_commands( self.database_manager.get_commands()) self.smart_home_activator.set_log_manager(self.database_manager, self.logger)
class HandGestureDetector(): def __init__(self): self.process_manager = ProcessManager() self.fist = Gesture("fist.xml") self.palm = Gesture("palm.xml") def detect(self, frame, flipped_frame, has_made_fist, has_made_palm): self.process_manager.add_process( self.fist.detect, (frame, flipped_frame, has_made_fist, 'fist')) self.process_manager.add_process( self.palm.detect, (frame, flipped_frame, has_made_palm, 'palm')) self.process_manager.on_done()
class EtlProcess(object): """ This class will manage the high level data processing, calling on the ProcessRun module to access the data controller modules @AppSetup - a class object that can create the sessions """ def __init__(self, appSetup): self.sesSource = appSetup.getSourceSession() self.sesTarget = appSetup.getTargetSession() sesManager = appSetup.getTargetSession() self.manager = ProcessManager(sesManager) def runProcesses(self): """ The controller for the applications processes. Using the EtlRun class and BioBiRun class """ logger.info('ETL process run in SUBQUERY mode: BEGINNING') try: runSubQ_mode = EtlRun(self.sesSource, self.sesTarget) runSubQ_mode.runMe() logger.info('ETL process run in SUBQUERY mode: COMPLETED') self.manager.updateRunStatus('Subquery mode finished') except Exception as e: self.manager.badRun() raise e if runSubQ_mode.getMissingEmplid(): logger.info( 'SUBQUERY mode: Discovered {} missing emplids.'.format( len(runSubQ_mode.getMissingEmplid()))) logger.info('ETL process run in LIST mode: BEGINNING') try: self.manager.updateRunStatus('List mode started') runList_mode = EtlRun(self.sesSource, self.sesTarget, runSubQ_mode.getMissingEmplid()) runList_mode.runMe() logger.info('ETL process run in LIST mode: COMPLETED') except Exception as e: self.manager.badRun(", ".join(runSubQ_mode.getMissingEmplid())) raise e for emplid in runList_mode.getMissingEmplid(): """There should NOT be a reason as to why we had a missing value here log it and move forward.""" logger.warning( "Unable to process data for emplid: {}".format(emplid)) else: logger.info('SUBQUERY mode: NO missing emplids discovered.') logger.info('BI process run: BEGINNING') try: self.manager.updateRunStatus('Starting BI process') runBi = BioBiRun(self.sesTarget) runBi.run_bi_x() logger.info('BI process run: COMPLETED') except Exception as e: self.manager.badRun(", ".join(runSubQ_mode.getMissingEmplid())) raise e self.manager.goodRun(", ".join(runSubQ_mode.getMissingEmplid())) self.manager.removeOldRuns()
def __init__(self, appSetup): self.sesSource = appSetup.getSourceSession() self.sesTarget = appSetup.getTargetSession() sesManager = appSetup.getTargetSession() self.manager = ProcessManager(sesManager)
def __init__(self): self.process_manager = ProcessManager() self.fist = Gesture("fist.xml") self.palm = Gesture("palm.xml")
def __set_up_helpers__(self): self.process_manager = ProcessManager() self.hand_gesture_detector = HandGestureDetector() self.blink_detector = BlinkDetector()
class HtpcLauncherApp: def __init__(self, ostools = None, config = None): self.ostools = ostools if not self.ostools: self.ostools = OsTools() self.config = config if not self.config: self.config = Config() self._startLogging() self._loadConfig() self._startFileLogging() self.irReader = IrReader() self.processManager = ProcessManager() def run(self): try: self._processIrCode(self.config.getLaunchCommand()) while True: try: try: code = self.irReader.getNextCode() except IrReaderError: time.sleep(5) continue self._processIrCode(code) except KeyboardInterrupt: break except: self.log.exception('Unhandled exception') def _startFileLogging(self): formatter = logging.Formatter('%(asctime)s %(levelname)s - %(message)s') filePath = os.path.expanduser(DEFAULT_LOG_FILE) self.log.info('Logging to %s', self.config.getLogPath()) handler = self.ostools.getRotatingLogHandler(self.config.getLogPath(), maxBytes = 1024000, backupCount = 5) handler.setFormatter(formatter) self.log.addHandler(handler) def _startLogging(self): self.log = logging.getLogger() self.log.setLevel(logging.DEBUG) self.log.addHandler(logging.StreamHandler()) def _loadConfig(self): self.log.info('Loading config file from home directory') configFile = self.ostools.openUserFile('.%s' % DEFAULT_CONF_FILE) if not configFile: self.log.info('Config not found in home directory; loading from system config') configFile = self.ostools.openSystemConfFile(DEFAULT_CONF_FILE) if not configFile: raise RuntimeError('Failed to find configuration file') self.config.load(configFile) def _processIrCode(self, code): command = self.config.getCommand(code) if not command: return self.processManager.execute(command)