SHARE
TWEET

Untitled

a guest Jul 16th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/biomaj_download/download/ftp.py b/biomaj_download/download/ftp.py
  2. index 78b5d24..92dd0d6 100644
  3. --- a/biomaj_download/download/ftp.py
  4. +++ b/biomaj_download/download/ftp.py
  5. @@ -290,13 +290,17 @@ class FTPDownload(DownloadInterface):
  6.              # the individual fields in this list of parts
  7.              if not parts:
  8.                  continue
  9. -            rfile['permissions'] = parts[0]
  10. -            rfile['group'] = parts[2]
  11. -            rfile['user'] = parts[3]
  12. -            rfile['size'] = int(parts[4])
  13. -            rfile['month'] = Utils.month_to_num(parts[5])
  14. -            rfile['day'] = int(parts[6])
  15. -            rfile['hash'] = hashlib.md5(line.encode('utf-8')).hexdigest()
  16. +            try:
  17. +                rfile['permissions'] = parts[0]
  18. +                rfile['group'] = parts[2]
  19. +                rfile['user'] = parts[3]
  20. +                rfile['size'] = int(parts[4])
  21. +                rfile['month'] = Utils.month_to_num(parts[5])
  22. +                rfile['day'] = int(parts[6])
  23. +                rfile['hash'] = hashlib.md5(line.encode('utf-8')).hexdigest()
  24. +            except Exception:
  25. +                self.logger.error('Download:Skip: failed to read file info: ' + str(line))
  26. +                continue
  27.              try:
  28.                  rfile['year'] = int(parts[7])
  29.              except Exception:
  30. @@ -310,6 +314,7 @@ class FTPDownload(DownloadInterface):
  31.                  if rfile['month'] == curdate.month and rfile['day'] > curdate.day:
  32.                      rfile['year'] = curdate.year - 1
  33.              rfile['name'] = parts[8]
  34. +
  35.              for i in range(9, len(parts)):
  36.                  if parts[i] == '->':
  37.                      # Symlink, add to files AND dirs as we don't know the type of the link
  38. @@ -318,6 +323,10 @@ class FTPDownload(DownloadInterface):
  39.                  else:
  40.                      rfile['name'] += ' ' + parts[i]
  41.  
  42. +            if rfile['name'] == '':
  43. +                self.logger.error('Download:Skip: failed to read file name: ' + str(line))
  44. +                continue
  45. +
  46.              is_dir = False
  47.              if re.match('^d', rfile['permissions']):
  48.                  is_dir = True
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top