From ef7e91feab5237fea02ad69cf18c0bac204be77e Mon Sep 17 00:00:00 2001 From: Jonathan Eisenhamer Date: Mon, 1 Aug 2022 22:34:08 -0400 Subject: [PATCH] Change prd version printing to logging This allows wrapper scripts to more easily manage what is output from their execution. --- pysiaf/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pysiaf/__init__.py b/pysiaf/__init__.py index c402dba7..1ee41c14 100644 --- a/pysiaf/__init__.py +++ b/pysiaf/__init__.py @@ -3,9 +3,13 @@ """ from __future__ import absolute_import, print_function, division +import logging import re import requests +# Configure logging +logger = logging.getLogger(__name__) + from pkg_resources import get_distribution, DistributionNotFound try: __version__ = get_distribution(__name__).version @@ -34,9 +38,9 @@ is False][-1] # choose largest number from PRDs matching format: PRODOSSOC-### if JWST_PRD_VERSION != newest_prd: - print("**WARNING**: LOCAL JWST PRD VERSION {} DOESN'T MATCH THE CURRENT ONLINE VERSION {}\nPlease " - "consider updating pysiaf, e.g. pip install --upgrade pysiaf or conda update pysiaf".format( - JWST_PRD_VERSION, newest_prd)) + logger.warning("**WARNING**: LOCAL JWST PRD VERSION %s DOESN'T MATCH THE CURRENT ONLINE VERSION %s" + "\nPlease consider updating pysiaf, e.g. pip install --upgrade pysiaf or conda update pysiaf", + JWST_PRD_VERSION, newest_prd) except: - print("**WARNING**: LOCAL JWST PRD VERSION {} CANNOT BE CHECKED AGAINST ONLINE VERSION".format(JWST_PRD_VERSION)) + logger.warning("**WARNING**: LOCAL JWST PRD VERSION %s CANNOT BE CHECKED AGAINST ONLINE VERSION", JWST_PRD_VERSION) pass