temporarily removed the progressbar due to problems with logging

master
TiynGER 4 years ago
parent 6f9ef9bbd6
commit 564a9ba977

@ -1,7 +1,7 @@
import time import time
import logging as log import logging as log
from tqdm import tqdm #from tqdm import tqdm
import requests as req import requests as req
from requests.auth import HTTPBasicAuth from requests.auth import HTTPBasicAuth
@ -80,7 +80,6 @@ class Studip:
rsp = self.auth_req('/api.php/user/' + user_id + '/courses') rsp = self.auth_req('/api.php/user/' + user_id + '/courses')
ord_sems = self.get_ordered_semesters() ord_sems = self.get_ordered_semesters()
courses = rsp.json()['collection'] courses = rsp.json()['collection']
i = 0
course_list = {} course_list = {}
for course_uri in courses: for course_uri in courses:
course = courses[course_uri] course = courses[course_uri]
@ -147,12 +146,12 @@ class Studip:
last_dl = self.db.get_last_file_dl(doc) last_dl = self.db.get_last_file_dl(doc)
if last_dl == None or last_dl < doc_chdate: if last_dl == None or last_dl < doc_chdate:
rsp2 = self.auth_req('/api.php/file/' + doc + '/download') rsp2 = self.auth_req('/api.php/file/' + doc + '/download')
total_size = int(rsp2.headers.get('content-length', 0)) #total_size = int(rsp2.headers.get('content-length', 0))
print('downloading ' + doc_name) log.info('downloading ' + doc_name)
progbar = tqdm(total=total_size, unit='iB', unit_scale=True) #progbar = tqdm(total=total_size, unit='iB', unit_scale=True)
with open(doc_name, 'wb') as doc_file: with open(doc_name, 'wb') as doc_file:
for chunk in rsp2.iter_content(self.CHUNK_SIZE): for chunk in rsp2.iter_content(self.CHUNK_SIZE):
progbar.update(len(chunk)) #progbar.update(len(chunk))
doc_file.write(chunk) doc_file.write(chunk)
self.db.set_last_file_dl(str(doc), str(int(time.time()))) self.db.set_last_file_dl(str(doc), str(int(time.time())))

Loading…
Cancel
Save