diff --git a/ChangeLog b/ChangeLog index 4e9c616..f0941b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2015-06-19 Juergen Knoedlseder +2015-07-03 Juergen Knoedlseder * Version 0.10.0 released ========================= + Add csinfo script (#1489) Add cterror tool Check existence of ROI in ctbin (#1476) Allocate optimizer in ctlike upon construction (#1471) diff --git a/NEWS b/NEWS index 799f061..1f88acf 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 0.10.0 Author(s) : Juergen Knoedlseder -19 June 2015 +3 July 2015 1. Introduction @@ -109,7 +109,8 @@ None 20. Scripts ----------- -None +Added csinfo script to provide some information about the GammaLib and ctools +installation. To be run in case of problems to help diagnostics. 21. caldb diff --git a/scripts/Makefile.am b/scripts/Makefile.am index d887637..fb55b1d 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -5,14 +5,15 @@ binscripts = cta_kb_bkgrates.py cta_root2irf.py cta_make_nodes.py \ tsmerge.py # Scripts to be distributed in pythondir -pythonscripts = cspull.py cssens.py cstsdist.py cscaldb.py csresmap.py cshessobs.py \ - csobsdef.py csspec.py cslightcrv.py \ +pythonscripts = cspull.py cssens.py cstsdist.py cscaldb.py csresmap.py \ + cshessobs.py csobsdef.py csspec.py cslightcrv.py \ + csinfo.py \ lsmodel.py # Scripts for which symbolic links will be created in bindir linkscripts = cspull cssens cstsdist cscaldb csresmap \ - csobsdef csspec cshessobs cslightcrv \ - lsmodel csinfo + cshessobs csobsdef csspec cslightcrv \ + csinfo lsmodel # Distribute scripts EXTRA_DIST = $(binscripts) $(pythonscripts) diff --git a/scripts/csinfo.py b/scripts/csinfo.py index 409d5ce..9fb4219 100755 --- a/scripts/csinfo.py +++ b/scripts/csinfo.py @@ -20,7 +20,7 @@ # ========================================================================== import sys import os -import subprocess +import commands # Copied and edited a bit from the `doc/source/reference_manual/index.rst` file # The list there and here needs to be manually updated and kept in sync. @@ -39,8 +39,10 @@ CTOOL_LIST = """ cttsmap Generates Test Statistics map ctulimit Calculates upper limit cterror Calculates likelihood profile errors - +""" +CSCRIPT_LIST = """ cscaldb Lists available instrument response functions + csinfo Checks ctools and GammaLib installations csobsdef Generates observation definition file cslightcrv Computes lightcurve cspull Generates pull distribution @@ -59,17 +61,23 @@ def log(text, end='\n'): sys.stdout.write(text + end) -def print_ctools_list(): +def csinfo_list_tools(): """Print available ctools with one-line description to the console. """ print('\nAvailable ctools:') print(CTOOL_LIST) + print('Available cscripts:') + print(CSCRIPT_LIST) def csinfo_setup_check(): - print('\nGammalib / ctools setup info:\n') + print('\nGammalib / ctools setup check:\n') - all_ok = True + all_ok = True + gammalib_environ = False + ctools_environ = False + gammalib_python = False + ctools_python = False log(' GAMMALIB environment variable ... ', end='') try: @@ -77,7 +85,8 @@ def csinfo_setup_check(): print('ok') except KeyError: print('NOT OK') - all_ok = False + all_ok = False + gammalib_environ = True log(' CTOOLS environment variable ... ', end='') try: @@ -85,7 +94,8 @@ def csinfo_setup_check(): print('ok') except KeyError: print('NOT_OK') - all_ok = False + all_ok = False + ctools_environ = True log(' gammalib Python import .......... ', end='') try: @@ -93,7 +103,8 @@ def csinfo_setup_check(): print('ok') except: print('NOT OK') - all_ok = False + all_ok = False + gammalib_python = True log(' ctools Python import .......... ', end='') try: @@ -101,19 +112,26 @@ def csinfo_setup_check(): print('ok') except: print('NOT OK') - all_ok = False + all_ok = False + ctools_python = True if all_ok: - print('\n Your Gammalib / ctools setup is OK.\n') + print('\n Your Gammalib / ctools setup is OK.') else: print('\n WARNING: Your Gammalib / ctools setup is NOT OK!\n') - print(' - Did you source gammalib-init.sh ?') - print(' - Did you source gammalib-ctools.sh ?') - print(' - Are you using the correct Python ?') + if gammalib_environ: + print(' - Have you set the GAMMALIB environment variable?') + print(' - Did you source gammalib-init.sh?') + if ctools_environ: + print(' - Have you set the CTOOLS environment variable?') + print(' - Did you source ctools-init.sh ?') + if gammalib_python or ctools_python: + print(' - Are you using the correct Python ?') - print() + print('') def csinfo_setup_info(): + print('\nGammalib / ctools setup info:\n') log(' CTOOLS environment variable ... ', end='') try: @@ -138,12 +156,12 @@ def csinfo_setup_info(): print(' GAMMALIB CFLAGS: {0}'.format(get_pkg_config_info('cflags', 'gammalib'))) print(' CTOOLS CFLAGS: {0}'.format(get_pkg_config_info('cflags', 'ctools'))) - print() + print('') def get_pkg_config_info(info, library): cmd = 'pkg-config --{0} {1}'.format(info, library) - out = subprocess.getoutput(cmd) + out = commands.getoutput(cmd) if 'was not found' in out: return 'Not available' else: @@ -153,10 +171,10 @@ def get_pkg_config_info(info, library): def csinfo_print_help(): print('\nPrint info about Gammalib and ctools to the console.\n') print('Available commands:') - print(' csinfo tools List available ctools') - print(' csinfo setup-check Check Gammalib / ctools setup') - print(' csinfo setup-info Print Gammalib / ctools setup info') - print() + print(' csinfo list List available ctools and cscripts') + print(' csinfo check Check Gammalib / ctools setup') + print(' csinfo info Print Gammalib / ctools setup info') + print('') def csinfo(argv): @@ -167,11 +185,11 @@ def csinfo(argv): sys.exit(0) cmd = argv[1] - if cmd == 'list-tools': + if cmd == 'list': csinfo_list_tools() - elif cmd == 'setup-check': + elif cmd == 'check': csinfo_setup_check() - elif cmd == 'setup-info': + elif cmd == 'info': csinfo_setup_info() else: print('\nERROR: invalid command: `{0}`'.format(cmd))