@@ -102,14 +102,40 @@ def get_environmental_data(
102102 log .debug (
103103 "Fetching environmental data for location" , location_code = location_code
104104 )
105- yield from client .paginate (
106- f"enviro/{ location_code } " ,
107- method = "get" ,
108- params = {
109- "begin_dt" : begin_date ,
110- "end_dt" : end_date ,
111- },
112- )
105+ try :
106+ yield from client .paginate (
107+ f"enviro/{ location_code } " ,
108+ method = "get" ,
109+ params = {
110+ "begin_dt" : begin_date ,
111+ "end_dt" : end_date ,
112+ },
113+ )
114+ except requests .exceptions .HTTPError as e :
115+ if e .response is not None and e .response .status_code == 403 :
116+ log .warning (
117+ f"403 Forbidden error for environmental data at location "
118+ f"{ location_code } . Skipping this location." ,
119+ location_code = location_code ,
120+ error = str (e ),
121+ )
122+ else :
123+ log .error (
124+ f"HTTP error fetching environmental data for location "
125+ f"{ location_code } " ,
126+ location_code = location_code ,
127+ status_code = e .response .status_code if e .response else None ,
128+ error = str (e ),
129+ )
130+ continue
131+ except Exception as e :
132+ log .error (
133+ f"Unexpected error fetching environmental data for location "
134+ f"{ location_code } " ,
135+ location_code = location_code ,
136+ error = str (e ),
137+ )
138+ continue
113139
114140
115141def get_tags_data (
@@ -119,14 +145,38 @@ def get_tags_data(
119145 for location_name in locations :
120146 location_code = SITES .get (location_name )
121147 log .debug ("Fetching tags data for location" , location_code = location_code )
122- yield from client .paginate (
123- f"tags/{ location_code } " ,
124- method = "get" ,
125- params = {
126- "begin_dt" : begin_date ,
127- "end_dt" : end_date ,
128- },
129- )
148+ try :
149+ yield from client .paginate (
150+ f"tags/{ location_code } " ,
151+ method = "get" ,
152+ params = {
153+ "begin_dt" : begin_date ,
154+ "end_dt" : end_date ,
155+ },
156+ )
157+ except requests .exceptions .HTTPError as e :
158+ if e .response is not None and e .response .status_code == 403 :
159+ log .warning (
160+ f"403 Forbidden error for tags data at location "
161+ f"{ location_code } . Skipping this location." ,
162+ location_code = location_code ,
163+ error = str (e ),
164+ )
165+ else :
166+ log .error (
167+ f"HTTP error fetching tags data for location { location_code } " ,
168+ location_code = location_code ,
169+ status_code = e .response .status_code if e .response else None ,
170+ error = str (e ),
171+ )
172+ continue
173+ except Exception as e :
174+ log .error (
175+ f"Unexpected error fetching tags data for location { location_code } " ,
176+ location_code = location_code ,
177+ error = str (e ),
178+ )
179+ continue
130180
131181
132182def get_readers_voltage_data (
@@ -139,14 +189,40 @@ def get_readers_voltage_data(
139189 log .debug (
140190 "Fetching readers voltage data for location" , location_code = location_code
141191 )
142- yield from client .paginate (
143- f"reader/{ location_code } " ,
144- method = "get" ,
145- params = {
146- "begin_dt" : begin_date ,
147- "end_dt" : end_date ,
148- },
149- )
192+ try :
193+ yield from client .paginate (
194+ f"reader/{ location_code } " ,
195+ method = "get" ,
196+ params = {
197+ "begin_dt" : begin_date ,
198+ "end_dt" : end_date ,
199+ },
200+ )
201+ except requests .exceptions .HTTPError as e :
202+ if e .response is not None and e .response .status_code == 403 :
203+ log .warning (
204+ f"403 Forbidden error for readers voltage data at location "
205+ f"{ location_code } . Skipping this location." ,
206+ location_code = location_code ,
207+ error = str (e ),
208+ )
209+ else :
210+ log .error (
211+ f"HTTP error fetching readers voltage data for location"
212+ f"{ location_code } " ,
213+ location_code = location_code ,
214+ status_code = e .response .status_code if e .response else None ,
215+ error = str (e ),
216+ )
217+ continue
218+ except Exception as e :
219+ log .error (
220+ f"Unexpected error fetching readers voltage data for location "
221+ f"{ location_code } " ,
222+ location_code = location_code ,
223+ error = str (e ),
224+ )
225+ continue
150226
151227
152228@dlt .transformer (primary_key = ["tag" , "detected_at" ])
0 commit comments