def download_device(headers, cookies, temp_target_disk, device_url, lease_updater, total_bytes_written, total_bytes_to_write):
 with open(temp_target_disk, 'wb') as handle:
  response = requests.get(device_url, stream=True, headers=headers, cookies=cookies, verify=False)
  if (not response.ok):
   response.raise_for_status()
  current_bytes_written = 0
  for block in response.iter_content(chunk_size=2048):
   if block:
    handle.write(block)
    handle.flush()
    os.fsync(handle.fileno())
   current_bytes_written += len(block)
   written_pct = (((current_bytes_written + total_bytes_written) * 100) / total_bytes_to_write)
   lease_updater.progressPercent = int(written_pct)
 return current_bytes_written

def download_device ( headers , cookies , temp_target_disk , device_url , lease_updater , total_bytes_written , total_bytes_to_write ) : with open ( temp_target_disk , 'wb' ) as handle : response = requests . get ( device_url , stream = True , headers = headers , cookies = cookies , verify = False ) if ( not response . ok ) : response . raise_for_status ( ) current_bytes_written = 0 for block in response . iter_content ( chunk_size = 2048 ) : if block : handle . write ( block ) handle . flush ( ) os . fsync ( handle . fileno ( ) ) current_bytes_written += len ( block ) written_pct = ( ( ( current_bytes_written + total_bytes_written ) * 100 ) / total_bytes_to_write ) lease_updater . progressPercent = int ( written_pct ) return current_bytes_written
download disk device of httpnfclease .