def _check_status(self): bail = 0 # Check to see if the hotplug lock file exists. If so, bail for now. hotstat = PROC.status_from_name('hotplug') if hotstat.state != PROC.StatusEnum.DOESNOTEXIST: # Looks like it exists. Bail for now. bail = 1 if not bail: _dstatus = self._do_check() if _dstatus != self._drives: # If it has changed, wait a couple of seconds, and # make sure we aren't stomping on hotplug. time.sleep(2) # hotstat = PROC.status_from_name('hotplug') if hotstat.state != PROC.StatusEnum.DOESNOTEXIST: # Looks like it exists. Bail for now. bail = 1 if bail: mstr = 'hotplug lock file exists. Not checking USB status. ' mstr += 'Got pid of %d.' % hotstat.pid msglog.log('USBStorage', msglog.types.WARN, mstr) return 1 # if _dstatus and (_dstatus != self._drives): print 'Drive status has changed to %s.' % str(_dstatus) # Since drive status has changed, check for the hotplug lock file # again. This should guard against the case where the kernel # detects the device and starts to run hotplug but this routine # gets in first. hotstat = PROC.status_from_name('hotplug') if hotstat.state != PROC.StatusEnum.DOESNOTEXIST: mstr = 'hotplug lock file exists now. Not checking USB status. ' mstr += 'Got pid of %d.' % hotstat.pid msglog.log('USBStorage', msglog.types.WARN, mstr) return 1 for x in _dstatus: if not x in self._drives: self._add_services_node(x) self._add_device_node(x) self._add_device_event(x) for x in self._drives: if not x in _dstatus: self._remove_services_node(x) self._remove_device_node(x) self._remove_device_event(x) self._drives = _dstatus return 0
def is_running(): # Check this process. if (__system_dict['run_func'] != None): return 1 # Check for another process. if (process.status_from_name('broadway').state != process.StatusEnum.DOESNOTEXIST): return 1 return 0