私の要件では、http urlからパッケージをダウンロードし、同じものの進捗状況を確認する必要があります。urlopenを使用してプログレスバーをダウンロードする
は、私はあなたが私はそこdownload.Isコードに最小限の変更でどのような方法の進行状況を確認するために基本的にLinuxのコマンドを使用している見ることができるように私は、水平方向の進捗を持つことができます
import subprocess
from urllib import urlopen
class MyClass(object):
'''
classdocs
'''
def url_to_download(self):
url_for_download = "someurl"
file = "somefilename"
print "downloading with urllib"
response = urlopen(url_for_download)
CHUNK = 16 * 1024
with open(file, 'wb') as f:
while True:
chunk = response.read(CHUNK)
cmd = "ls -ltrh" + " " +file + " "+ "|"+ "awk '{print $5}'"
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
print "the download progress is" + " " + str(output)
if not chunk:
break
f.write(chunk)
if __name__ == "__main__":
download = MyClass()
download.number_of_files()
download.url_to_download()
書かれたコードの下に持っていますダウンロードの詳細。 ありがとうございます。
ありがとうalot.iはtqdmで動作しました –