def download_and_extract(URL):
 if (URL == None):
  logger.warning('Please provide URL')
  return None
 tmpdir = tempfile.mkdtemp()
 filename = os.path.basename(URL)
 path = ((tmpdir + '/') + filename)
 zdata = urllib2.urlopen(URL)
 print 'Saving file to disk please wait....'
 with open(path, 'wb') as local_file:
  local_file.write(zdata.read())
 zfile = zipfile.ZipFile(path)
 print 'Extracting zipfile'
 try:
  zfile.extractall(tmpdir)
 except:
  logger.warning("Couldn't extract zip file")
  return None
 return tmpdir

def download_and_extract ( URL ) : if ( URL == None ) : logger . warning ( 'Please provide URL' ) return None tmpdir = tempfile . mkdtemp ( ) filename = os . path . basename ( URL ) path = ( ( tmpdir + '/' ) + filename ) zdata = urllib2 . urlopen ( URL ) print 'Saving file to disk please wait....' with open ( path , 'wb' ) as local_file : local_file . write ( zdata . read ( ) ) zfile = zipfile . ZipFile ( path ) print 'Extracting zipfile' try : zfile . extractall ( tmpdir ) except : logger . warning ( "Couldn't extract zip file" ) return None return tmpdir
this function takes in a url for a zip file .