예제 #1
0
def rotatorJson():
    try:
        global lastRotate
        if (datetime.now() - lastRotate).total_seconds() < JSON_FILE_DUMP_TIME:
            return
        debug('rotatorJson called')
        lastRotate = datetime.now()
        ThreadPool.Submit(rotatorJsonMp)
    except:
        exception('rotatorJson exception')
예제 #2
0
파일: sensors.py 프로젝트: moauyed/sensors
 def InitCallbacks(self):
     """Set callback function for any digital devices that support them"""
     devices = manager.getDeviceList()
     for device in devices:
         sensor = instance.deviceInstance(device['name'])
         if 'DigitalSensor' in device['type'] and hasattr(sensor, 'setCallback'):
             debug('Set callback for {}'.format(sensor))
             sensor.setCallback(self.OnSensorChange, device)
             if not self.realTimeMonitorRunning:
                 ThreadPool.Submit(self.RealTimeMonitor)
예제 #3
0
파일: sensors.py 프로젝트: moauyed/sensors
    def OnPluginChange(self, data):
        """Callback that is called when digital sensor data has changed

        Args:
            data: The new data value
        """
        debug('OnPluginChange: {}'.format(data))
        self.QueueRealTimeData(data['id'], data)
        with self.realTimeMutex:
            if not self.realTimeMonitorRunning:
                ThreadPool.Submit(self.RealTimeMonitor)
예제 #4
0
 def Destroy(self):
     """Destroy client and stop client threads"""
     info('Shutting down client')
     self.exiting.set()
     if hasattr(self, 'sensorsClient'):
         self.sensorsClient.StopMonitoring()
     if hasattr(self, 'schedulerEngine'):
         self.schedulerEngine.stop()
     if hasattr(self, 'updater'):
         self.updater.stop()
     if hasattr(self, 'writerThread'):
         self.writerThread.stop()
     if hasattr(self, 'processorThread'):
         self.processorThread.stop()
     ThreadPool.Shutdown()
     self.Disconnect()
     info('Client shut down')
예제 #5
0
 def ExecuteConfigCommand(config_id, parameters=''):
     """Execute specified command to modify configuration
     
     Args:
         config_id: Id of command to run
         parameters: Parameters to use when executing command
     """
     if not Hardware().isRaspberryPi():
         return (1, 'Not supported')
     debug('SystemConfig::ExecuteConfigCommand')
     if config_id == 0:
         return SystemConfig.ExpandRootfs()
     command = "sudo " + CUSTOM_CONFIG_SCRIPT + " " + str(
         config_id) + " " + str(parameters)
     (output, returnCode) = executeCommand(command)
     debug('ExecuteConfigCommand ' + str(config_id) + ' args: ' +
           str(parameters) + ' retCode: ' + str(returnCode) + ' output: ' +
           output)
     if "reboot required" in output:
         ThreadPool.Submit(SystemConfig.RestartDevice)
     return (returnCode, output)
예제 #6
0
 def calibrating(self):
     if not self.isCalibrated:
         ThreadPool.Submit(self.doCalibrating())
예제 #7
0
파일: sensors.py 프로젝트: moauyed/sensors
 def StartMonitoring(self):
     """Start thread monitoring sensor data"""
     ThreadPool.Submit(self.Monitor)
예제 #8
0
 def Start(self):
     """Start download speed thread"""
     ThreadPool.Submit(self.Test)