예제 #1
0
 def _read_lock(self):
     """
     Read the values from the lock file. Returns None if there is no current lock file.
     """
     if self.lockfile and os.path.exists(self.lockfile):
         result = {}
         with io.open(self.lockfile, encoding='utf-8') as f:
             lines = [l for l in f.readlines() if l]
         for line in lines:
             try:
                 key, value = line.split(':', 1)
             except ValueError:
                 log.debug('Invalid line in lock file: %s' % line)
                 continue
             result[key.strip().lower()] = value.strip()
         for key in result:
             if result[key].isdigit():
                 result[key] = native_int(result[key])
         result.setdefault('pid', None)
         if not result['pid']:
             log.error(
                 'Invalid lock file. Make sure FlexGet is not running, then delete it.'
             )
         elif not pid_exists(result['pid']):
             return None
         return result
     return None
예제 #2
0
파일: manager.py 프로젝트: Lukeid/Flexget
 def _read_lock(self):
     """
     Read the values from the lock file. Returns None if there is no current lock file.
     """
     if self.lockfile and os.path.exists(self.lockfile):
         result = {}
         with io.open(self.lockfile, encoding='utf-8') as f:
             lines = [l for l in f.readlines() if l]
         for line in lines:
             try:
                 key, value = line.split(':', 1)
             except ValueError:
                 log.debug('Invalid line in lock file: %s' % line)
                 continue
             result[key.strip().lower()] = value.strip()
         for key in result:
             if result[key].isdigit():
                 result[key] = int(result[key])
         result.setdefault('pid', None)
         if not result['pid']:
             log.error('Invalid lock file. Make sure FlexGet is not running, then delete it.')
         elif not pid_exists(result['pid']):
             return None
         return result
     return None
예제 #3
0
파일: manager.py 프로젝트: Klaboe/Flexget
    def check_lock(self):
        """Checks if there is already a lock, returns True if there is."""
        if os.path.exists(self.lockfile):
            with open(self.lockfile) as f:
                pid = f.read()
            pid = int(pid.lstrip('PID: '))

            if not pid_exists(pid):
                log.info('PID %s no longer exists, ignoring lock file.' % pid)
                return False

            return True
        return False
예제 #4
0
 def _read_lock(self):
     """
     Read the values from the lock file. Returns None if there is no current lock file.
     """
     if self.lockfile and os.path.exists(self.lockfile):
         result = {}
         with open(self.lockfile) as f:
             lines = [l for l in f.readlines() if l]
         for line in lines:
             key, value = line.split(b':', 1)
             result[key.strip().lower()] = value.strip()
         for key in result:
             if result[key].isdigit():
                 result[key] = int(result[key])
         if not pid_exists(result['pid']):
             return None
         return result
     return None
예제 #5
0
파일: manager.py 프로젝트: andir/Flexget
 def _read_lock(self):
     """
     Read the values from the lock file. Returns None if there is no current lock file.
     """
     if self.lockfile and os.path.exists(self.lockfile):
         result = {}
         with open(self.lockfile) as f:
             lines = [l for l in f.readlines() if l]
         for line in lines:
             key, value = line.split(b':', 1)
             result[key.strip().lower()] = value.strip()
         for key in result:
             if result[key].isdigit():
                 result[key] = int(result[key])
         if not pid_exists(result['pid']):
             return None
         return result
     return None
예제 #6
0
파일: manager.py 프로젝트: thisirs/Flexget
 def _read_lock(self):
     """
     Read the values from the lock file. Returns None if there is no current lock file.
     """
     if self.lockfile and os.path.exists(self.lockfile):
         result = {}
         with open(self.lockfile) as f:
             lines = [l for l in f.readlines() if l]
         for line in lines:
             key, value = line.split(b':', 1)
             result[key.strip().lower()] = value.strip()
         for key in result:
             if result[key].isdigit():
                 result[key] = int(result[key])
         result.setdefault('pid', None)
         if not result['pid']:
             log.error(
                 'Invalid lock file. Make sure FlexGet is not running, then delete it.'
             )
         elif not pid_exists(result['pid']):
             return None
         return result
     return None