Commit 05b33a6be58c216f51d1f15953943af46f4b1270

Authored by Jürgen Knödlseder
1 parent 18741613

Import and test IACT scripts only for Python 2.6 or later.

ChangeLog
1   -2016-02-25 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
  1 +2016-02-26 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
2 2  
3 3 * Version 1.1.0 released
4 4 ========================
5 5  
  6 + Test and import IACT scripts only for Python 2.6+ (#1715)
6 7 Adapt to revise GTime operators (#1714)
7 8 Add publish() methods to tools producing images (#1710)
8 9 Read ahead output filename in cterror (#1700)
... ...
... ... @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 1.1.0
2 2  
3 3 Author(s) : Juergen Knoedlseder
4 4  
5   -25 February 2016
  5 +26 February 2016
6 6  
7 7  
8 8 1. Introduction
... ... @@ -18,7 +18,10 @@ None
18 18  
19 19 3. Python interface
20 20 -------------------
21   -None
  21 +The IACT scripts csfindobs, csiactcopy, csiactdata, and csiactobs are only
  22 +imported into th cscripts module and tested if the Python version is 2.6 or
  23 +newer. These scripts make use of the json Python module that is only became
  24 +available from Python 2.6 on.
22 25  
23 26  
24 27 4. Support model
... ...
configure.ac
... ... @@ -603,9 +603,9 @@ if test &quot;x$ac_enable_python_binding&quot; = &quot;xno&quot;; then
603 603 else
604 604  
605 605 # Do we have Python and Python.h?
606   - AM_PATH_PYTHON([2.5],
  606 + AM_PATH_PYTHON([2.3],
607 607 [has_python="yes"],
608   - [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])])
  608 + [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])])
609 609  
610 610 # It would really be weired if Python has not been found, as barely every system has Python. Maybe
611 611 # it was not found because the autoconf is so old, and in an early version of the AM_PATH_PYTHON
... ...
cscripts/Makefile.am
... ... @@ -3,16 +3,18 @@
3 3 # Scripts to be distributed in $(pyexecdir)/cscripts
4 4 pythonscripts = __init__.py \
5 5 cspull.py cssens.py cstsdist.py cscaldb.py csresmap.py \
6   - csiactobs.py csiactdata.py csobsdef.py csspec.py cslightcrv.py csobsinfo.py \
  6 + csobsdef.py csspec.py cslightcrv.py csobsinfo.py \
7 7 csinfo.py csmodelinfo.py csmodelmerge.py cstsmapmerge.py \
8   - csobs2caldb.py csfindobs.py csiactcopy.py \
  8 + csobs2caldb.py \
  9 + csfindobs.py csiactcopy.py csiactdata.py csiactobs.py \
9 10 obsutils.py
10 11  
11 12 # Scripts for which symbolic links will be created in bindir
12 13 linkscripts = cspull cssens cstsdist cscaldb csresmap \
13   - csiactobs csiactdata csobsdef csspec cslightcrv csobsinfo \
  14 + csobsdef csspec cslightcrv csobsinfo \
14 15 csinfo csmodelinfo csmodelmerge cstsmapmerge \
15   - csobs2caldb csfindobs csiactcopy
  16 + csobs2caldb \
  17 + csfindobs csiactcopy csiactdata csiactobs
16 18  
17 19 # Distribute scripts
18 20 EXTRA_DIST = $(binscripts) $(pythonscripts)
... ...
cscripts/__init__.py.in
1 1 # ==========================================================================
2 2 # cscripts Python module
3 3 #
4   -# Copyright (C) 2015 Juergen Knoedlseder
  4 +# Copyright (C) 2015-2016 Juergen Knoedlseder
5 5 #
6 6 # This program is free software: you can redistribute it and/or modify
7 7 # it under the terms of the GNU General Public License as published by
... ... @@ -17,12 +17,14 @@
17 17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 18 #
19 19 # ==========================================================================
  20 +# Python version check
  21 +import sys
  22 +req_version = (2,7)
  23 +cur_version = sys.version_info
20 24  
21 25 # List all scripts in this module
22 26 __all__ = [
23 27 "cscaldb",
24   - "csiactdata",
25   - "csiactobs",
26 28 "csinfo",
27 29 "cslightcrv",
28 30 "csmodelinfo",
... ... @@ -37,17 +39,18 @@ __all__ = [
37 39 "cstsdist",
38 40 "cstsmapmerge",
39 41 "csfindobs",
40   - "csiactobs",
41   - "csiactdata",
42   - "csiactcopy",
43 42 "obsutils",
44 43 "test",
45 44 ]
  45 +if cur_version > req_version:
  46 + __all__.extend(["csfindobs",
  47 + "csiactcopy",
  48 + "csiactdata",
  49 + "csiactobs"])
  50 +
46 51  
47 52 # Import
48 53 from .cscaldb import cscaldb
49   -from .csiactdata import csiactdata
50   -from .csiactobs import csiactobs
51 54 from .csinfo import csinfo
52 55 from .cslightcrv import cslightcrv
53 56 from .csmodelinfo import csmodelinfo
... ... @@ -61,11 +64,17 @@ from .cssens import cssens
61 64 from .csspec import csspec
62 65 from .cstsdist import cstsdist
63 66 from .cstsmapmerge import cstsmapmerge
64   -from .csfindobs import csfindobs
65   -from .csiactobs import csiactobs
66   -from .csiactdata import csiactdata
67   -from .csiactcopy import csiactcopy
68 67 from . import obsutils
  68 +if cur_version > req_version:
  69 + from .csfindobs import csfindobs
  70 + from .csiactcopy import csiactcopy
  71 + from .csiactdata import csiactdata
  72 + from .csiactobs import csiactobs
  73 +
  74 +# Delete version check variables
  75 +del sys
  76 +del req_version
  77 +del cur_version
69 78  
70 79 # Add test function
71 80 def test():
... ...
test/test_cscripts.sh.in
... ... @@ -483,66 +483,74 @@ $ECHO &quot; ok&quot;
483 483  
484 484  
485 485 #
486   -# Test csiactcopy
487   -# ===============
488   -$ECHO -n "Test csiactcopy: "
489   -chmod +x @abs_top_srcdir@/cscripts/csiactcopy.py
490   -@abs_top_srcdir@/cscripts/csiactcopy.py \
491   - remote_master="iactdata/master.json" \
492   - outpath="iactdata_test" \
493   - prodname="unit-test" > csiactcopy.log
494   -$ECHO -n "."
495   -if [ -s "iactdata_test/master.json" ]
496   -then
  486 +# Optional tests for Python 2.6++ (scripts needing json module)
  487 +# =============================================================
  488 +python_version=`echo @PYTHON_VERSION@ | sed 's/\(10\.[[0-9]]*\).*/\1/' | sed -e 's/\.//g'`
  489 +if [ $python_version -ge 26 ]; then
  490 +
  491 + #
  492 + # Test csfindobs
  493 + # ==============
  494 + $ECHO -n "Test csfindobs: "
  495 + chmod +x @abs_top_srcdir@/cscripts/csfindobs.py
  496 + @abs_top_srcdir@/cscripts/csfindobs.py \
  497 + datapath="iactdata/" \
  498 + prodname="unit-test" \
  499 + ra="83.6331" \
  500 + dec="22.01" \
  501 + rad="1.0" \
  502 + outfile="iactrunlist.dat" > csfindobs.log
497 503 $ECHO -n "."
498   -else
499   - $ECHO " iactdata_test/master.json file is not valid"
500   - exit 1
501   -fi
502   -$ECHO " ok"
503   -
504   -
505   -#
506   -# Test csfindobs
507   -# ==============
508   -$ECHO -n "Test csfindobs: "
509   -chmod +x @abs_top_srcdir@/cscripts/csfindobs.py
510   -@abs_top_srcdir@/cscripts/csfindobs.py \
511   - datapath="iactdata/" \
512   - prodname="unit-test" \
513   - ra="83.6331" \
514   - dec="22.01" \
515   - rad="1.0" \
516   - outfile="iactrunlist.dat" > csfindobs.log
517   -$ECHO -n "."
518   -if [ -s "iactrunlist.dat" ]
519   -then
  504 + if [ -s "iactrunlist.dat" ]
  505 + then
  506 + $ECHO -n "."
  507 + else
  508 + $ECHO " iactdata/runlist.txt file is not valid"
  509 + exit 1
  510 + fi
  511 + $ECHO " ok"
  512 +
  513 +
  514 + #
  515 + # Test csiactcopy
  516 + # ===============
  517 + $ECHO -n "Test csiactcopy: "
  518 + chmod +x @abs_top_srcdir@/cscripts/csiactcopy.py
  519 + @abs_top_srcdir@/cscripts/csiactcopy.py \
  520 + remote_master="iactdata/master.json" \
  521 + outpath="iactdata_test" \
  522 + prodname="unit-test" > csiactcopy.log
520 523 $ECHO -n "."
521   -else
522   - $ECHO " iactdata/runlist.txt file is not valid"
523   - exit 1
524   -fi
525   -$ECHO " ok"
526   -
527   -
528   -#
529   -# Test csiactobs
530   -# ==============
531   -$ECHO -n "Test csiactobs: "
532   -chmod +x @abs_top_srcdir@/cscripts/csiactobs.py
533   -@abs_top_srcdir@/cscripts/csiactobs.py \
534   - datapath="iactdata/" \
535   - prodname="unit-test" \
536   - infile="iactrunlist.dat" \
537   - bkgpars="1" \
538   - outobs="obs2.xml" \
539   - outmodel="bkgmodels.xml" > csiactobs.log
540   -$ECHO -n "."
541   -if [ -s "obs2.xml" ]
542   -then
  524 + if [ -s "iactdata_test/master.json" ]
  525 + then
  526 + $ECHO -n "."
  527 + else
  528 + $ECHO " iactdata_test/master.json file is not valid"
  529 + exit 1
  530 + fi
  531 + $ECHO " ok"
  532 +
  533 +
  534 + #
  535 + # Test csiactobs
  536 + # ==============
  537 + $ECHO -n "Test csiactobs: "
  538 + chmod +x @abs_top_srcdir@/cscripts/csiactobs.py
  539 + @abs_top_srcdir@/cscripts/csiactobs.py \
  540 + datapath="iactdata/" \
  541 + prodname="unit-test" \
  542 + infile="iactrunlist.dat" \
  543 + bkgpars="1" \
  544 + outobs="obs2.xml" \
  545 + outmodel="bkgmodels.xml" > csiactobs.log
543 546 $ECHO -n "."
544   -else
545   - $ECHO " obs.xml file is not valid"
546   - exit 1
547   -fi
548   -$ECHO " ok"
  547 + if [ -s "obs2.xml" ]
  548 + then
  549 + $ECHO -n "."
  550 + else
  551 + $ECHO " obs.xml file is not valid"
  552 + exit 1
  553 + fi
  554 + $ECHO " ok"
  555 +
  556 +fi # Python 2.6+ specific tests
... ...