brynq-sdk-zermelo 1.0.1__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/PKG-INFO +1 -1
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/brynq_sdk/zermelo/zermelo.py +35 -13
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/brynq_sdk_zermelo.egg-info/PKG-INFO +1 -1
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/setup.py +1 -1
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/brynq_sdk/zermelo/__init__.py +0 -0
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/brynq_sdk_zermelo.egg-info/SOURCES.txt +0 -0
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/brynq_sdk_zermelo.egg-info/dependency_links.txt +0 -0
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/brynq_sdk_zermelo.egg-info/not-zip-safe +0 -0
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/brynq_sdk_zermelo.egg-info/requires.txt +0 -0
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/brynq_sdk_zermelo.egg-info/top_level.txt +0 -0
- {brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/setup.cfg +0 -0
|
@@ -332,7 +332,7 @@ class Zermelo(BrynQ):
|
|
|
332
332
|
df.index.name = 'appointments_{0}_id'.format(col_name)
|
|
333
333
|
df.to_csv(file, sep='|', decimal=',')
|
|
334
334
|
|
|
335
|
-
def get_zermelo_filtered(self, endpoint: str, fields: List = None, startdate
|
|
335
|
+
def get_zermelo_filtered(self, endpoint: str, fields: List = None, startdate=None, enddate=None, filters: dict = None) -> pd.DataFrame:
|
|
336
336
|
"""
|
|
337
337
|
:param endpoint: endpoint
|
|
338
338
|
:param fields: fields to get, if left empty, all fields are returned
|
|
@@ -341,7 +341,7 @@ class Zermelo(BrynQ):
|
|
|
341
341
|
:param filters: dict of fields with corresponding values to filter
|
|
342
342
|
:return:
|
|
343
343
|
"""
|
|
344
|
-
# Loop through the data per
|
|
344
|
+
# Loop through the data per 7 days (3600 seconds * 24 hours * 7 days) because the dataset is too big to receive at once.
|
|
345
345
|
df = pd.DataFrame()
|
|
346
346
|
url = f'{self.url}{endpoint}'
|
|
347
347
|
params = {'access_token': self.access_token}
|
|
@@ -354,33 +354,55 @@ class Zermelo(BrynQ):
|
|
|
354
354
|
if startdate is not None:
|
|
355
355
|
start_epoch = int(time.mktime(startdate))
|
|
356
356
|
last_epoch = int(time.mktime(enddate))
|
|
357
|
-
# loop epoch is
|
|
357
|
+
# loop epoch is 7 days from start_date except when last_epoch is smaller than start + 7 days
|
|
358
358
|
end_epoch = int(start_epoch + (3600 * 24 * 7)) if (start_epoch + (3600 * 24 * 7)) < last_epoch else last_epoch
|
|
359
|
+
|
|
359
360
|
while start_epoch < last_epoch:
|
|
360
361
|
try:
|
|
361
362
|
# merge params with loop params
|
|
362
363
|
time_params = params | {'start': start_epoch, 'end': end_epoch}
|
|
363
|
-
resp = requests.get(url=url,
|
|
364
|
-
params=time_params
|
|
365
|
-
)
|
|
364
|
+
resp = requests.get(url=url, params=time_params)
|
|
366
365
|
resp.raise_for_status()
|
|
366
|
+
|
|
367
367
|
data = resp.json()['response']['data']
|
|
368
368
|
|
|
369
369
|
# checks if data is not empty list
|
|
370
370
|
if len(data) > 0:
|
|
371
371
|
df = pd.concat([df, pd.DataFrame(data)])
|
|
372
372
|
|
|
373
|
+
# move to next 7-day block
|
|
373
374
|
start_epoch += (3600 * 24 * 7)
|
|
374
375
|
end_epoch += (3600 * 24 * 7)
|
|
376
|
+
# Adjust end_epoch to not exceed last_epoch
|
|
377
|
+
if end_epoch > last_epoch:
|
|
378
|
+
end_epoch = last_epoch
|
|
379
|
+
|
|
380
|
+
except requests.exceptions.HTTPError as http_err:
|
|
381
|
+
# Stop the loop for certain HTTP errors like 403 or 401
|
|
382
|
+
if resp.status_code == 403:
|
|
383
|
+
print('{} - 403 Forbidden at timestamp {}: {}'.format(time.strftime('%H:%M:%S'), start_epoch, http_err))
|
|
384
|
+
break # Stop the loop for 403 error
|
|
385
|
+
elif resp.status_code == 401:
|
|
386
|
+
print('{} - 401 Unauthorized at timestamp {}: {}'.format(time.strftime('%H:%M:%S'), start_epoch, http_err))
|
|
387
|
+
break # Stop the loop for 401 error
|
|
388
|
+
|
|
389
|
+
# For other HTTP errors, retry the loop
|
|
390
|
+
print('{} - HTTP Error at timestamp {}: {}'.format(time.strftime('%H:%M:%S'), start_epoch, http_err))
|
|
391
|
+
start_epoch += (3600 * 24 * 7) # Move forward to next block to prevent endless retry
|
|
375
392
|
|
|
376
393
|
except Exception as e:
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
394
|
+
# Handle other types of exceptions (e.g., network errors)
|
|
395
|
+
print('{} - General Error at timestamp {}: {}'.format(time.strftime('%H:%M:%S'), start_epoch, e))
|
|
396
|
+
start_epoch += (3600 * 24 * 7) # Skip this block to avoid infinite retry
|
|
380
397
|
else:
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
398
|
+
try:
|
|
399
|
+
resp = requests.get(url=url, params=params)
|
|
400
|
+
resp.raise_for_status()
|
|
401
|
+
data = resp.json()['response']['data']
|
|
402
|
+
df = pd.DataFrame(data)
|
|
403
|
+
except requests.exceptions.HTTPError as http_err:
|
|
404
|
+
print('{} - HTTP Error: {}'.format(time.strftime('%H:%M:%S'), http_err))
|
|
405
|
+
except Exception as e:
|
|
406
|
+
print('{} - General Error: {}'.format(time.strftime('%H:%M:%S'), e))
|
|
385
407
|
|
|
386
408
|
return df
|
|
File without changes
|
|
File without changes
|
{brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/brynq_sdk_zermelo.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{brynq_sdk_zermelo-1.0.1 → brynq_sdk_zermelo-1.0.2}/brynq_sdk_zermelo.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|