python 2.7 - How to check if .tar.gz archive corrupted after download? -


i use python 2.7.8 , request library download tar.gz archives usgs.gov site.

data example: http://dds.cr.usgs.gov/ltaauth//data/standard_l1t/etm/29/30/2016/le70290302016178edc00.tar.gz?id=48aq2ki3sr01iq18pdo8jdmi47&iid=le70290302016178edc00&did=252710635&ver=production

sometimes connection interrupted , not files uncompressed archive (but file not corrupted completely). use following code (a part of it) download data:

import requests import traceback  def download_file(url, file_path):     # note stream=true parameter     r = requests.get(url, timeout=120, stream=true)     open(file_path, 'wb') f:         chunk in r.iter_content(chunk_size=1024):              if chunk:                 f.write(chunk)         return file_path  try:     download_file(url, scene_path)     except:     traceback.print_exc()      if os.path.isfile(scene_path):         os.remove(scene_path)         print u'<= del' 

how check if *.tar.gz archive corrupted after download?


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

android - CoordinatorLayout, FAB and container layout conflict -