def total_blocks_and_bytes(self):
total_blocks, total_bytes = 0, 0
for u in self.input_urls:
head_response_headers = requests.head(u).headers
if 'Content-Length' not in head_response_headers:
m = "The url: '{}' doesn't support the 'Content-Length' field.".format(u)
raise ContentLengthNotSupportedException(m)
else:
remote_size = int(head_response_headers['Content-Length'])
total_bytes += remote_size
num_blocks, last_block_size = divmod(remote_size, self.blocksize)
total_blocks += num_blocks
if last_block_size:
total_blocks += 1
return total_blocks, total_bytes
评论列表
文章目录