diff --git a/ChangeLog b/ChangeLog index 152d70f..02c6590 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2016-02-25 Juergen Knoedlseder +2016-02-26 Juergen Knoedlseder * Version 1.1.0 released ======================== + Test and import IACT scripts only for Python 2.6+ (#1715) Adapt to revise GTime operators (#1714) Add publish() methods to tools producing images (#1710) Read ahead output filename in cterror (#1700) diff --git a/NEWS b/NEWS index 2753ebf..a96e772 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 1.1.0 Author(s) : Juergen Knoedlseder -25 February 2016 +26 February 2016 1. Introduction @@ -18,7 +18,10 @@ None 3. Python interface ------------------- -None +The IACT scripts csfindobs, csiactcopy, csiactdata, and csiactobs are only +imported into th cscripts module and tested if the Python version is 2.6 or +newer. These scripts make use of the json Python module that is only became +available from Python 2.6 on. 4. Support model diff --git a/configure.ac b/configure.ac index 3444a68..da38597 100644 --- a/configure.ac +++ b/configure.ac @@ -603,9 +603,9 @@ if test "x$ac_enable_python_binding" = "xno"; then else # Do we have Python and Python.h? - AM_PATH_PYTHON([2.5], + AM_PATH_PYTHON([2.3], [has_python="yes"], - [AC_MSG_WARN([Python >= 2.5 not found. Python >= 2.5 is required to build python binding. Python can be obtained from http://www.python.org])]) + [AC_MSG_WARN([Python >= 2.3 not found. Python >= 2.3 is required to build python binding. Python can be obtained from http://www.python.org])]) # It would really be weired if Python has not been found, as barely every system has Python. Maybe # it was not found because the autoconf is so old, and in an early version of the AM_PATH_PYTHON diff --git a/cscripts/Makefile.am b/cscripts/Makefile.am index d480368..85aefd0 100644 --- a/cscripts/Makefile.am +++ b/cscripts/Makefile.am @@ -3,16 +3,18 @@ # Scripts to be distributed in $(pyexecdir)/cscripts pythonscripts = __init__.py \ cspull.py cssens.py cstsdist.py cscaldb.py csresmap.py \ - csiactobs.py csiactdata.py csobsdef.py csspec.py cslightcrv.py csobsinfo.py \ + csobsdef.py csspec.py cslightcrv.py csobsinfo.py \ csinfo.py csmodelinfo.py csmodelmerge.py cstsmapmerge.py \ - csobs2caldb.py csfindobs.py csiactcopy.py \ + csobs2caldb.py \ + csfindobs.py csiactcopy.py csiactdata.py csiactobs.py \ obsutils.py # Scripts for which symbolic links will be created in bindir linkscripts = cspull cssens cstsdist cscaldb csresmap \ - csiactobs csiactdata csobsdef csspec cslightcrv csobsinfo \ + csobsdef csspec cslightcrv csobsinfo \ csinfo csmodelinfo csmodelmerge cstsmapmerge \ - csobs2caldb csfindobs csiactcopy + csobs2caldb \ + csfindobs csiactcopy csiactdata csiactobs # Distribute scripts EXTRA_DIST = $(binscripts) $(pythonscripts) diff --git a/cscripts/__init__.py.in b/cscripts/__init__.py.in index d67c23b..0b22dd1 100644 --- a/cscripts/__init__.py.in +++ b/cscripts/__init__.py.in @@ -1,7 +1,7 @@ # ========================================================================== # cscripts Python module # -# Copyright (C) 2015 Juergen Knoedlseder +# Copyright (C) 2015-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,12 +17,14 @@ # along with this program. If not, see . # # ========================================================================== +# Python version check +import sys +req_version = (2,7) +cur_version = sys.version_info # List all scripts in this module __all__ = [ "cscaldb", - "csiactdata", - "csiactobs", "csinfo", "cslightcrv", "csmodelinfo", @@ -37,17 +39,18 @@ __all__ = [ "cstsdist", "cstsmapmerge", "csfindobs", - "csiactobs", - "csiactdata", - "csiactcopy", "obsutils", "test", ] +if cur_version > req_version: + __all__.extend(["csfindobs", + "csiactcopy", + "csiactdata", + "csiactobs"]) + # Import from .cscaldb import cscaldb -from .csiactdata import csiactdata -from .csiactobs import csiactobs from .csinfo import csinfo from .cslightcrv import cslightcrv from .csmodelinfo import csmodelinfo @@ -61,11 +64,17 @@ from .cssens import cssens from .csspec import csspec from .cstsdist import cstsdist from .cstsmapmerge import cstsmapmerge -from .csfindobs import csfindobs -from .csiactobs import csiactobs -from .csiactdata import csiactdata -from .csiactcopy import csiactcopy from . import obsutils +if cur_version > req_version: + from .csfindobs import csfindobs + from .csiactcopy import csiactcopy + from .csiactdata import csiactdata + from .csiactobs import csiactobs + +# Delete version check variables +del sys +del req_version +del cur_version # Add test function def test(): diff --git a/test/test_cscripts.sh.in b/test/test_cscripts.sh.in index 475bde3..e367823 100755 --- a/test/test_cscripts.sh.in +++ b/test/test_cscripts.sh.in @@ -483,66 +483,74 @@ $ECHO " ok" # -# Test csiactcopy -# =============== -$ECHO -n "Test csiactcopy: " -chmod +x @abs_top_srcdir@/cscripts/csiactcopy.py -@abs_top_srcdir@/cscripts/csiactcopy.py \ - remote_master="iactdata/master.json" \ - outpath="iactdata_test" \ - prodname="unit-test" > csiactcopy.log -$ECHO -n "." -if [ -s "iactdata_test/master.json" ] -then +# Optional tests for Python 2.6++ (scripts needing json module) +# ============================================================= +python_version=`echo @PYTHON_VERSION@ | sed 's/\(10\.[[0-9]]*\).*/\1/' | sed -e 's/\.//g'` +if [ $python_version -ge 26 ]; then + + # + # Test csfindobs + # ============== + $ECHO -n "Test csfindobs: " + chmod +x @abs_top_srcdir@/cscripts/csfindobs.py + @abs_top_srcdir@/cscripts/csfindobs.py \ + datapath="iactdata/" \ + prodname="unit-test" \ + ra="83.6331" \ + dec="22.01" \ + rad="1.0" \ + outfile="iactrunlist.dat" > csfindobs.log $ECHO -n "." -else - $ECHO " iactdata_test/master.json file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test csfindobs -# ============== -$ECHO -n "Test csfindobs: " -chmod +x @abs_top_srcdir@/cscripts/csfindobs.py -@abs_top_srcdir@/cscripts/csfindobs.py \ - datapath="iactdata/" \ - prodname="unit-test" \ - ra="83.6331" \ - dec="22.01" \ - rad="1.0" \ - outfile="iactrunlist.dat" > csfindobs.log -$ECHO -n "." -if [ -s "iactrunlist.dat" ] -then + if [ -s "iactrunlist.dat" ] + then + $ECHO -n "." + else + $ECHO " iactdata/runlist.txt file is not valid" + exit 1 + fi + $ECHO " ok" + + + # + # Test csiactcopy + # =============== + $ECHO -n "Test csiactcopy: " + chmod +x @abs_top_srcdir@/cscripts/csiactcopy.py + @abs_top_srcdir@/cscripts/csiactcopy.py \ + remote_master="iactdata/master.json" \ + outpath="iactdata_test" \ + prodname="unit-test" > csiactcopy.log $ECHO -n "." -else - $ECHO " iactdata/runlist.txt file is not valid" - exit 1 -fi -$ECHO " ok" - - -# -# Test csiactobs -# ============== -$ECHO -n "Test csiactobs: " -chmod +x @abs_top_srcdir@/cscripts/csiactobs.py -@abs_top_srcdir@/cscripts/csiactobs.py \ - datapath="iactdata/" \ - prodname="unit-test" \ - infile="iactrunlist.dat" \ - bkgpars="1" \ - outobs="obs2.xml" \ - outmodel="bkgmodels.xml" > csiactobs.log -$ECHO -n "." -if [ -s "obs2.xml" ] -then + if [ -s "iactdata_test/master.json" ] + then + $ECHO -n "." + else + $ECHO " iactdata_test/master.json file is not valid" + exit 1 + fi + $ECHO " ok" + + + # + # Test csiactobs + # ============== + $ECHO -n "Test csiactobs: " + chmod +x @abs_top_srcdir@/cscripts/csiactobs.py + @abs_top_srcdir@/cscripts/csiactobs.py \ + datapath="iactdata/" \ + prodname="unit-test" \ + infile="iactrunlist.dat" \ + bkgpars="1" \ + outobs="obs2.xml" \ + outmodel="bkgmodels.xml" > csiactobs.log $ECHO -n "." -else - $ECHO " obs.xml file is not valid" - exit 1 -fi -$ECHO " ok" + if [ -s "obs2.xml" ] + then + $ECHO -n "." + else + $ECHO " obs.xml file is not valid" + exit 1 + fi + $ECHO " ok" + +fi # Python 2.6+ specific tests