| Ryan10145 added a comment. |
I'm running into a problem with this task. From the line response = fetch(url, stream=True), I assumed that the file is not being downloaded on that line, and rather it will wait until the data is accessed to begin downloading it. Therefore, I thought that I could put any download bar code inside of
for data in response.data.iter_content(100 * 1024):
result_file.write(data)To test this, I put pywikibot.output('test') right after result_file.write(data)
However, when I did this and ran the script, the console stopped for ~10 seconds, and then printed my test code multiple times extremely rapidly.After this, I tested the line response = fetch(url, stream=True) by putting a print statement before it and right after it. The result was that the first one would print, then there would be a ~10 second wait, and then the second one would print.
All of this leads me to believe that the response = fetch(url, stream=True) is actually downloading the file, and
for data in response.data.iter_content(100 * 1024): result_file.write(data)is just writing the downloaded data to the file. As a result, I am confused on how to make a download bar. How can I check the download progress and print it out to the user while the download is still occurring if I can't put it in the above?
Cc: rafidaslam, pywikibot-bugs-list, eflyjason, Aklapper, Xqt, zhuyifei1999, jayvdb, siebrand, Zoranzoki21, Framawiki, Bright1055, Toppole69, Mine0901, Jayprakash12345, Magul, Tbscho, MayS, Beeyan, Mdupont, JJMC89, MtDu, D3r1ck01, Avicennasis, Dalba, Masti, Alchimista, Rxy
_______________________________________________ pywikibot-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs
