コード例 #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
ファイル: manager.py プロジェクト: parhuzamos/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
コード例 #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