def task_download_report(self, task_item):
uri = task_item.data['uri']
#size = task_item.data['size']
#file_format = task_item.data['format']
md5 = task_item.data['md5']
save_path = task_item.data['save_path']
def report(count, blockSize, totalSize):
#update percent
task_item.percent = ("%.2f" % (count*blockSize*100/totalSize))
task_item.consuming = int(time.time() - self.begin_handle_time)
pass
filename = commands.getoutput('basename %s' % uri)
file_abs_path = save_path + '/' + filename
urllib.urlretrieve(uri, file_abs_path, reporthook=report)
this_md5 = commands.getoutput("md5sum %s | awk '{print $1}' " % file_abs_path)
if this_md5 == md5:
return {"status_code": 0, "msg":"OK"}
else:
#os.system("rm -f %s" % file_abs_path)
return {"status_code": -1, "msg":"md5 doesn't match"}
评论列表
文章目录