From ad97b4e06bfc739983e6651c17d19dda3117f510 Mon Sep 17 00:00:00 2001 From: bkatiemills Date: Thu, 25 Jul 2024 15:36:25 -0400 Subject: [PATCH] fallback for version fishing --- argovisHelpers/helpers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/argovisHelpers/helpers.py b/argovisHelpers/helpers.py index 55e1827..136bdb9 100644 --- a/argovisHelpers/helpers.py +++ b/argovisHelpers/helpers.py @@ -3,6 +3,7 @@ from shapely.ops import orient import geopandas as gpd import pkg_resources +from pkg_resources import DistributionNotFound def slice_timesteps(options, r): # given a qsr option dict and data route, return a list of reasonable time divisions @@ -224,7 +225,11 @@ def argofetch(route, options={}, apikey='', apiroot='https://argovis-api.colorad if option in options: options[option] = str(options[option]) - dl = requests.get(apiroot.rstrip('/') + '/' + route.lstrip('/'), params = options, headers={'x-argokey': apikey, 'x-avh-telemetry': pkg_resources.get_distribution('argovisHelpers').version}) + try: + version = pkg_resources.get_distribution('argovisHelpers').version + except DistributionNotFound: + version = '-1' + dl = requests.get(apiroot.rstrip('/') + '/' + route.lstrip('/'), params = options, headers={'x-argokey': apikey, 'x-avh-telemetry': version}) statuscode = dl.status_code if verbose: print(urllib.parse.unquote(dl.url))