Skip to content

Commit

Permalink
Update app/content_service/get_lecture_from_artemis.py
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
yassinsws and coderabbitai[bot] authored Mar 24, 2024
1 parent b0291b1 commit 7211386
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/content_service/get_lecture_from_artemis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ def download_lecture_pdf(base_url: str, unit_id: int) -> tempfile.NamedTemporary
artemis_url = f"{base_url}/api/v1/public/pyris/data/lecture-units/{unit_id}/pdf"
response = requests.get(artemis_url, stream=True)
if response.status_code != 200:
print(f"Failed to download the file. Status code: {response.status_code}")
raise ConnectionError
raise ConnectionError(f"Failed to download the file. Status code: {response.status_code}, URL: {artemis_url}")

temp_file = tempfile.NamedTemporaryFile()
for chunk in response.iter_content(chunk_size=DOWNLOAD_BUFFER_SIZE):
if chunk:
temp_file.write(chunk)
return temp_file
with tempfile.NamedTemporaryFile() as temp_file:
for chunk in response.iter_content(chunk_size=DOWNLOAD_BUFFER_SIZE):
if chunk:
temp_file.write(chunk)
return temp_file

0 comments on commit 7211386

Please sign in to comment.