Skip to content

Commit

Permalink
Merge pull request #95 from shanosborne/version_checking
Browse files Browse the repository at this point in the history
Add check upon import for JWST PRD version
  • Loading branch information
Johannes-Sahlmann authored Oct 22, 2019
2 parents ca8350c + 8454eb7 commit faa97d5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pysiaf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

from __future__ import absolute_import, print_function, division

import re
import requests

from .version import *

from .aperture import Aperture, HstAperture, JwstAperture
Expand All @@ -14,4 +17,20 @@
# from .tests import test_aperture#, test_polynomial
from .utils import polynomial, rotations, tools, projection

__all__ = ['Aperture', 'HstAperture', 'JwstAperture', 'SIAF', 'JWST_PRD_VERSION', 'JWST_PRD_DATA_ROOT', 'HST_PRD_VERSION', 'HST_PRD_DATA_ROOT', '_JWST_STAGING_ROOT', 'siaf', 'iando', 'polynomial', 'rotations', 'tools', 'compare', 'JWST_PRD_DATA_ROOT_EXCEL', 'generate', 'projection']
__all__ = ['Aperture', 'HstAperture', 'JwstAperture', 'SIAF', 'JWST_PRD_VERSION', 'JWST_PRD_DATA_ROOT', 'HST_PRD_VERSION', 'HST_PRD_DATA_ROOT', '_JWST_STAGING_ROOT', 'siaf', 'iando', 'polynomial', 'rotations', 'tools', 'compare', 'JWST_PRD_DATA_ROOT_EXCEL', 'generate', 'projection']

# Check PRD version is up to date
try:
req = requests.get('https://github.com/spacetelescope/pysiaf/tree/master/pysiaf/prd_data/JWST').text
p = re.compile("/spacetelescope/pysiaf/tree/master/pysiaf/prd_data/JWST/(.*?)/SIAFXML")
prd_list = p.findall(req)
newest_prd = [x for x in sorted(prd_list, reverse=True)][0]

if JWST_PRD_VERSION != newest_prd:
print("**WARNING**: LOCAL JWST PRD VERSION {} IS BEHIND THE CURRENT ONLINE VERSION {}\nPlease "
"consider updating pysiaf, e.g. pip install --upgrade pysiaf or conda update pysiaf".format(
JWST_PRD_VERSION, newest_prd))
except requests.exceptions.ConnectionError:
print("**WARNING**: NO INTERNET CONNECTION\nLOCAL JWST PRD VERSION {} CANNOT BE CHECKED AGAINST "
"ONLINE VERSION".format(JWST_PRD_VERSION))
pass

0 comments on commit faa97d5

Please sign in to comment.