10
10
from datetime import date , datetime , timezone
11
11
from itertools import product
12
12
13
- import requests
14
13
from mammoth import convert_to_html # type: ignore
15
14
from sqlalchemy import insert
16
15
22
21
from ..utils .sentry import with_span
23
22
24
23
if typing .TYPE_CHECKING :
25
- from typing import Any , Iterator
24
+ from typing import Any
25
+ from collections .abc import Iterator
26
26
from mammoth .documents import Image # type: ignore
27
27
from sqlalchemy .orm import Session
28
28
from sentry_sdk .tracing import Span
@@ -49,6 +49,8 @@ def __init__(self, config: ConfigSourcesEClassroom, session: Session) -> None:
49
49
self .config = config
50
50
self .session = session
51
51
52
+ super ().__init__ ()
53
+
52
54
def get_documents (self ) -> Iterator [DocumentInfo ]:
53
55
"""Get all documents from the e-classroom."""
54
56
@@ -70,9 +72,9 @@ def _mark_course_viewed(self) -> None:
70
72
}
71
73
72
74
try :
73
- response = requests .post (self .config .webserviceUrl , params = params , data = data )
75
+ response = self . requests .post (self .config .webserviceUrl , params = params , data = data )
74
76
response .raise_for_status ()
75
- except (IOError , ValueError ) as error :
77
+ except (OSError , ValueError ) as error :
76
78
raise ClassroomApiError ("Error while accessing e-classroom API" ) from error
77
79
78
80
def _get_internal_urls (self ) -> Iterator [DocumentInfo ]:
@@ -86,11 +88,11 @@ def _get_internal_urls(self) -> Iterator[DocumentInfo]:
86
88
}
87
89
88
90
try :
89
- response = requests .post (self .config .webserviceUrl , params = params , data = data )
91
+ response = self . requests .post (self .config .webserviceUrl , params = params , data = data )
90
92
contents = response .json ()
91
93
92
94
response .raise_for_status ()
93
- except (IOError , ValueError ) as error :
95
+ except (OSError , ValueError ) as error :
94
96
raise ClassroomApiError ("Error while accessing e-classroom API" ) from error
95
97
96
98
# Handle API errors
@@ -129,11 +131,11 @@ def _get_external_urls(self) -> Iterator[DocumentInfo]:
129
131
}
130
132
131
133
try :
132
- response = requests .post (self .config .webserviceUrl , params = params , data = data )
134
+ response = self . requests .post (self .config .webserviceUrl , params = params , data = data )
133
135
contents = response .json ()
134
136
135
137
response .raise_for_status ()
136
- except (IOError , ValueError ) as error :
138
+ except (OSError , ValueError ) as error :
137
139
raise ClassroomApiError ("Error while accessing e-classroom API" ) from error
138
140
139
141
# Handle API errors
0 commit comments