Commit 4274a67e814dd80504c6fb22211987aac19063e1
1 parent
699cd5ee
Pass script name and version in _init_cscript()
Showing
17 changed files
with
41 additions
and
103 deletions
configure.ac
| ... | ... | @@ -32,8 +32,8 @@ AC_INIT([ctools], [1.5.0.dev1], [jurgen.knodlseder@irap.omp.eu], [ctools]) |
| 32 | 32 | AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp]) |
| 33 | 33 | AC_CONFIG_MACRO_DIR([m4]) |
| 34 | 34 | #AM_INIT_AUTOMAKE([gnu no-dependencies foreign]) |
| 35 | -AM_INIT_AUTOMAKE([gnu -Wno-portability foreign]) | |
| 36 | -#AM_INIT_AUTOMAKE([gnu -Wno-portability foreign serial-tests]) | |
| 35 | +#AM_INIT_AUTOMAKE([gnu -Wno-portability foreign]) | |
| 36 | +AM_INIT_AUTOMAKE([gnu -Wno-portability foreign serial-tests]) | |
| 37 | 37 | AC_CONFIG_HEADER([config.h]) |
| 38 | 38 | |
| 39 | 39 | ... | ... |
cscripts/cscaldb.py
| ... | ... | @@ -53,13 +53,8 @@ class cscaldb(ctools.cscript): |
| 53 | 53 | TypeError |
| 54 | 54 | An invalid number of command line arguments was provided. |
| 55 | 55 | """ |
| 56 | - # Set name | |
| 57 | - self._name = 'cscaldb' | |
| 58 | - self._version = ctools.__version__ | |
| 59 | - | |
| 60 | - # Initialise application by calling the appropriate class | |
| 61 | - # constructor. | |
| 62 | - self._init_cscript(argv) | |
| 56 | + # Initialise application by calling the base class constructor | |
| 57 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 63 | 58 | |
| 64 | 59 | # Return |
| 65 | 60 | return | ... | ... |
cscripts/csfindobs.py
| ... | ... | @@ -38,9 +38,10 @@ class csfindobs(ctools.cscript): |
| 38 | 38 | """ |
| 39 | 39 | Constructor |
| 40 | 40 | """ |
| 41 | + # Initialise application by calling the base class constructor | |
| 42 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 43 | + | |
| 41 | 44 | # Set name |
| 42 | - self._name = 'csfindobs' | |
| 43 | - self._version = ctools.__version__ | |
| 44 | 45 | self._datapath = os.getenv('VHEFITS','') |
| 45 | 46 | self._prodname = '' |
| 46 | 47 | self._select_radec = True |
| ... | ... | @@ -49,9 +50,6 @@ class csfindobs(ctools.cscript): |
| 49 | 50 | self._dec = 0.0 |
| 50 | 51 | self._obs_index = '' |
| 51 | 52 | self._runs = [] |
| 52 | - | |
| 53 | - # Initialise application by calling the appropriate class constructor | |
| 54 | - self._init_cscript(argv) | |
| 55 | 53 | |
| 56 | 54 | # Return |
| 57 | 55 | return | ... | ... |
cscripts/csiactcopy.py
| ... | ... | @@ -42,9 +42,10 @@ class csiactcopy(ctools.cscript): |
| 42 | 42 | """ |
| 43 | 43 | Constructor |
| 44 | 44 | """ |
| 45 | + # Initialise application by calling the base class constructor | |
| 46 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 47 | + | |
| 45 | 48 | # Set name |
| 46 | - self._name = 'csiactcopy' | |
| 47 | - self._version = ctools.__version__ | |
| 48 | 49 | self._datapath = os.getenv('VHEFITS','') |
| 49 | 50 | self._remote_master = gammalib.GFilename() |
| 50 | 51 | self._remote_base = '' |
| ... | ... | @@ -53,10 +54,6 @@ class csiactcopy(ctools.cscript): |
| 53 | 54 | self._runlist = gammalib.GFilename() |
| 54 | 55 | self._runs = [] |
| 55 | 56 | |
| 56 | - # Initialise application by calling the appropriate class | |
| 57 | - # constructor. | |
| 58 | - self._init_cscript(argv) | |
| 59 | - | |
| 60 | 57 | # Return |
| 61 | 58 | return |
| 62 | 59 | ... | ... |
cscripts/csiactdata.py
| ... | ... | @@ -43,18 +43,15 @@ class csiactdata(ctools.cscript): |
| 43 | 43 | """ |
| 44 | 44 | Constructor. |
| 45 | 45 | """ |
| 46 | + # Initialise application by calling the base class constructor | |
| 47 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 48 | + | |
| 46 | 49 | # Set name |
| 47 | - self._name = 'csiactdata' | |
| 48 | - self._version = ctools.__version__ | |
| 49 | 50 | self._datapath = os.getenv('VHEFITS','') |
| 50 | 51 | self._prodnames = [] |
| 51 | 52 | self._master_indx = '' |
| 52 | 53 | self._master_file = '' |
| 53 | 54 | |
| 54 | - # Initialise application by calling the appropriate class | |
| 55 | - # constructor. | |
| 56 | - self._init_cscript(argv) | |
| 57 | - | |
| 58 | 55 | # Return |
| 59 | 56 | return |
| 60 | 57 | ... | ... |
cscripts/csiactobs.py
| ... | ... | @@ -45,9 +45,8 @@ class csiactobs(ctools.cscript): |
| 45 | 45 | """ |
| 46 | 46 | Constructor |
| 47 | 47 | """ |
| 48 | - # Set name and version | |
| 49 | - self._name = 'csiactobs' | |
| 50 | - self._version = ctools.__version__ | |
| 48 | + # Initialise application by calling the base class constructor | |
| 49 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 51 | 50 | |
| 52 | 51 | # Initialise some members |
| 53 | 52 | self._obs = gammalib.GObservations() |
| ... | ... | @@ -82,9 +81,6 @@ class csiactobs(ctools.cscript): |
| 82 | 81 | self._xml.append(gammalib.GXmlElement('observation_list ' |
| 83 | 82 | 'title="observation list"')) |
| 84 | 83 | |
| 85 | - # Initialise application by calling the appropriate class constructor | |
| 86 | - self._init_cscript(argv) | |
| 87 | - | |
| 88 | 84 | # Append an observation list to XML instance |
| 89 | 85 | self._xml.append(gammalib.GXmlElement('observation_list title="observation list"')) |
| 90 | 86 | self._xml_obslist = self._xml.element('observation_list', 0) | ... | ... |
cscripts/csmodelinfo.py
| ... | ... | @@ -42,16 +42,12 @@ class csmodelinfo(ctools.cscript): |
| 42 | 42 | """ |
| 43 | 43 | Constructor |
| 44 | 44 | """ |
| 45 | - # Set name | |
| 46 | - self._name = 'csmodelinfo' | |
| 47 | - self._version = ctools.__version__ | |
| 45 | + # Initialise application by calling the base class constructor | |
| 46 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 48 | 47 | |
| 49 | 48 | # Initialise class members |
| 50 | 49 | self._models = gammalib.GModels() |
| 51 | 50 | |
| 52 | - # Initialise application by calling the appropriate class constructor | |
| 53 | - self._init_cscript(argv) | |
| 54 | - | |
| 55 | 51 | # Return |
| 56 | 52 | return |
| 57 | 53 | ... | ... |
cscripts/csmodelmerge.py
| ... | ... | @@ -41,18 +41,13 @@ class csmodelmerge(ctools.cscript): |
| 41 | 41 | """ |
| 42 | 42 | Constructor. |
| 43 | 43 | """ |
| 44 | - # Set name | |
| 45 | - self._name = 'csmodelmerge' | |
| 46 | - self._version = ctools.__version__ | |
| 44 | + # Initialise application by calling the base class constructor | |
| 45 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 47 | 46 | |
| 48 | 47 | # Initialise class members |
| 49 | 48 | self._files = None |
| 50 | 49 | self._models = gammalib.GModels() |
| 51 | 50 | |
| 52 | - # Initialise application by calling the appropriate class | |
| 53 | - # constructor. | |
| 54 | - self._init_cscript(argv) | |
| 55 | - | |
| 56 | 51 | # Return |
| 57 | 52 | return |
| 58 | 53 | ... | ... |
cscripts/csmodelsois.py
| ... | ... | @@ -50,17 +50,13 @@ class csmodelsois(ctools.cscript): |
| 50 | 50 | TypeError |
| 51 | 51 | An invalid number of command line arguments was provided. |
| 52 | 52 | """ |
| 53 | - # Set name and version | |
| 54 | - self._name = 'csmodelsois' | |
| 55 | - self._version = ctools.__version__ | |
| 53 | + # Initialise application by calling the base class constructor | |
| 54 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 56 | 55 | |
| 57 | 56 | # Initialize parameters |
| 58 | 57 | self._cubegen = ctools.ctmapcube() |
| 59 | 58 | self._models = gammalib.GModels() |
| 60 | 59 | self._cubemodels = gammalib.GModels() |
| 61 | - | |
| 62 | - # Initialise application by calling the appropriate class constructor | |
| 63 | - self._init_cscript(argv) | |
| 64 | 60 | |
| 65 | 61 | # Return |
| 66 | 62 | return | ... | ... |
cscripts/csobsdef.py
| ... | ... | @@ -84,18 +84,14 @@ class csobsdef(ctools.cscript): |
| 84 | 84 | List of IRAF command line parameter strings of the form |
| 85 | 85 | ``parameter=3``. |
| 86 | 86 | """ |
| 87 | - # Set name and version | |
| 88 | - self._name = 'csobsdef' | |
| 89 | - self._version = ctools.__version__ | |
| 87 | + # Initialise application by calling the base class constructor | |
| 88 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 90 | 89 | |
| 91 | 90 | # Initialise class members |
| 92 | 91 | self._obs = gammalib.GObservations() |
| 93 | 92 | self._pntdef = gammalib.GCsv() |
| 94 | 93 | self._tmin = 0.0 |
| 95 | 94 | |
| 96 | - # Initialise application by calling the appropriate class constructor | |
| 97 | - self._init_cscript(argv) | |
| 98 | - | |
| 99 | 95 | # Return |
| 100 | 96 | return |
| 101 | 97 | ... | ... |
cscripts/csroot2caldb.py
| ... | ... | @@ -48,12 +48,8 @@ class csroot2caldb(ctools.cscript): |
| 48 | 48 | """ |
| 49 | 49 | Constructor |
| 50 | 50 | """ |
| 51 | - # Set name | |
| 52 | - self._name = 'csroot2caldb' | |
| 53 | - self._version = ctools.__version__ | |
| 54 | - | |
| 55 | - # Initialise application by calling the appropriate class constructor | |
| 56 | - self._init_cscript(argv) | |
| 51 | + # Initialise application by calling the base class constructor | |
| 52 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 57 | 53 | |
| 58 | 54 | # Return |
| 59 | 55 | return | ... | ... |
cscripts/cssrcdetect.py
| ... | ... | @@ -38,9 +38,8 @@ class cssrcdetect(ctools.cscript): |
| 38 | 38 | """ |
| 39 | 39 | Constructor |
| 40 | 40 | """ |
| 41 | - # Set name | |
| 42 | - self._name = 'cssrcdetect' | |
| 43 | - self._version = ctools.__version__ | |
| 41 | + # Initialise application by calling the base class constructor | |
| 42 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 44 | 43 | |
| 45 | 44 | # Set protected members |
| 46 | 45 | self._models = gammalib.GModels() |
| ... | ... | @@ -52,9 +51,6 @@ class cssrcdetect(ctools.cscript): |
| 52 | 51 | else: |
| 53 | 52 | self._map = gammalib.GSkyMap() |
| 54 | 53 | |
| 55 | - # Initialise application by calling the appropriate class constructor | |
| 56 | - self._init_cscript(argv) | |
| 57 | - | |
| 58 | 54 | # Return |
| 59 | 55 | return |
| 60 | 56 | ... | ... |
cscripts/cstsmapmerge.py
| ... | ... | @@ -38,9 +38,8 @@ class cstsmapmerge(ctools.cscript): |
| 38 | 38 | """ |
| 39 | 39 | Constructor. |
| 40 | 40 | """ |
| 41 | - # Set name | |
| 42 | - self._name = 'cstsmapmerge' | |
| 43 | - self._version = ctools.__version__ | |
| 41 | + # Initialise application by calling the base class constructor | |
| 42 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 44 | 43 | |
| 45 | 44 | # Initialise class members |
| 46 | 45 | self._files = None |
| ... | ... | @@ -53,10 +52,6 @@ class cstsmapmerge(ctools.cscript): |
| 53 | 52 | self._overwrite = True |
| 54 | 53 | self._delete = False |
| 55 | 54 | |
| 56 | - # Initialise application by calling the appropriate class | |
| 57 | - # constructor. | |
| 58 | - self._init_cscript(argv) | |
| 59 | - | |
| 60 | 55 | # Return |
| 61 | 56 | return |
| 62 | 57 | ... | ... |
cscripts/csviscube.py
| ... | ... | @@ -48,16 +48,12 @@ class csviscube(ctools.cscript): |
| 48 | 48 | TypeError |
| 49 | 49 | An invalid number of command line arguments was provided. |
| 50 | 50 | """ |
| 51 | - # Set name | |
| 52 | - self._name = 'csviscube' | |
| 53 | - self._version = ctools.__version__ | |
| 51 | + # Initialise application by calling the base class constructor | |
| 52 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 54 | 53 | |
| 55 | 54 | # Initialise members |
| 56 | 55 | self._cube = gammalib.GSkyMap() |
| 57 | 56 | |
| 58 | - # Initialise application by calling the appropriate class constructor | |
| 59 | - self._init_cscript(argv) | |
| 60 | - | |
| 61 | 57 | # Return |
| 62 | 58 | return |
| 63 | 59 | |
| ... | ... | @@ -499,7 +495,7 @@ class csviscube(ctools.cscript): |
| 499 | 495 | |
| 500 | 496 | # Set default name is user name is empty |
| 501 | 497 | if not name: |
| 502 | - user_name = self._name | |
| 498 | + user_name = self._name() | |
| 503 | 499 | else: |
| 504 | 500 | user_name = name |
| 505 | 501 | ... | ... |
cscripts/csworkflow.py
| ... | ... | @@ -51,17 +51,13 @@ class csworkflow(ctools.cscript): |
| 51 | 51 | TypeError |
| 52 | 52 | An invalid number of command line arguments was provided. |
| 53 | 53 | """ |
| 54 | - # Set name and version | |
| 55 | - self._name = 'csworkflow' | |
| 56 | - self._version = ctools.__version__ | |
| 54 | + # Initialise application by calling the base class constructor | |
| 55 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 57 | 56 | |
| 58 | 57 | # Set members |
| 59 | 58 | self._workflow = gammalib.GXml() |
| 60 | 59 | self._actors = [] |
| 61 | 60 | |
| 62 | - # Initialise application by calling the appropriate class constructor | |
| 63 | - self._init_cscript(argv) | |
| 64 | - | |
| 65 | 61 | # Return |
| 66 | 62 | return |
| 67 | 63 | ... | ... |
pyext/ctool.i
| ... | ... | @@ -242,11 +242,11 @@ def _set_input_obs(self, argv): |
| 242 | 242 | cscript._set_input_obs = _set_input_obs |
| 243 | 243 | |
| 244 | 244 | # Initialise application by calling the appropriate class constructor |
| 245 | -def _init_cscript(self, argv): | |
| 245 | +def _init_cscript(self, name, version, argv): | |
| 246 | 246 | if len(argv) == 0: |
| 247 | - cscript.__init__(self, self._name, self._version) | |
| 247 | + cscript.__init__(self, name, version) | |
| 248 | 248 | elif len(argv) == 1: |
| 249 | - cscript.__init__(self, self._name, self._version, *argv) | |
| 249 | + cscript.__init__(self, name, version, *argv) | |
| 250 | 250 | else: |
| 251 | 251 | raise TypeError('Invalid number of arguments given.') |
| 252 | 252 | # Set logger properties | ... | ... |
test/test_cscript.py
| ... | ... | @@ -35,15 +35,8 @@ class cscript_test(ctools.cscript): |
| 35 | 35 | """ |
| 36 | 36 | Constructor |
| 37 | 37 | """ |
| 38 | - # Set name | |
| 39 | - self._name = 'cscript_test' | |
| 40 | - self._version = ctools.__version__ | |
| 41 | - | |
| 42 | - # Initialise observation container from constructor arguments | |
| 43 | - self._obs, argv = self._set_input_obs(argv) | |
| 44 | - | |
| 45 | - # Initialise application by calling the appropriate class constructor | |
| 46 | - self._init_cscript(argv) | |
| 38 | + # Initialise application by calling the base class constructor | |
| 39 | + self._init_cscript(self.__class__.__name__, ctools.__version__, argv) | |
| 47 | 40 | |
| 48 | 41 | # Return |
| 49 | 42 | return |
| ... | ... | @@ -153,7 +146,7 @@ class ctobservation_test(ctools.csobservation): |
| 153 | 146 | Constructor |
| 154 | 147 | """ |
| 155 | 148 | # Initialise application by calling the appropriate class constructor |
| 156 | - self._init_csobservation('ctobservation_test', ctools.__version__, argv) | |
| 149 | + self._init_csobservation(self.__class__.__name__, ctools.__version__, argv) | |
| 157 | 150 | |
| 158 | 151 | # Return |
| 159 | 152 | return |
| ... | ... | @@ -211,7 +204,7 @@ class ctlikelihood_test(ctools.cslikelihood): |
| 211 | 204 | Constructor |
| 212 | 205 | """ |
| 213 | 206 | # Initialise application by calling the appropriate class constructor |
| 214 | - self._init_cslikelihood('ctlikelihood_test', ctools.__version__, argv) | |
| 207 | + self._init_cslikelihood(self.__class__.__name__, ctools.__version__, argv) | |
| 215 | 208 | |
| 216 | 209 | # Return |
| 217 | 210 | return | ... | ... |