From 72aad6b0ee45a8e301a1fc0dc52be857f7e5ec54 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 20 Oct 2017 10:56:28 +0200 Subject: [PATCH] Put cscript.execute() method in the cscripts base class --- cscripts/cscaldb.py | 22 +++------------------- cscripts/csebins.py | 19 ------------------- cscripts/csfindobs.py | 19 ------------------- cscripts/csiactcopy.py | 17 ----------------- cscripts/csiactdata.py | 16 ---------------- cscripts/csiactobs.py | 19 ------------------- cscripts/cslightcrv.py | 19 ------------------- cscripts/csmodelinfo.py | 19 ------------------- cscripts/csmodelmerge.py | 19 ------------------- cscripts/csmodelselect.py | 19 ------------------- cscripts/csmodelsois.py | 19 ------------------- cscripts/csobs2caldb.py | 19 ------------------- cscripts/csobsdef.py | 19 ------------------- cscripts/csobsinfo.py | 19 ------------------- cscripts/csobsselect.py | 19 ------------------- cscripts/csphagen.py | 19 ------------------- cscripts/csphasecrv.py | 19 ------------------- cscripts/cspull.py | 16 ---------------- cscripts/csresmap.py | 19 ------------------- cscripts/csroot2caldb.py | 16 ---------------- cscripts/cssens.py | 16 ---------------- cscripts/csspec.py | 19 ------------------- cscripts/cssrcdetect.py | 19 ------------------- cscripts/cstsdist.py | 16 ---------------- cscripts/cstsmapmerge.py | 19 ------------------- cscripts/cstsmapsplit.py | 19 ------------------- cscripts/csviscube.py | 19 ------------------- cscripts/csworkflow.py | 16 ---------------- pyext/ctool.i | 10 +++++++++- 29 files changed, 12 insertions(+), 513 deletions(-) diff --git a/cscripts/cscaldb.py b/cscripts/cscaldb.py index 4693653..3427869 100755 --- a/cscripts/cscaldb.py +++ b/cscripts/cscaldb.py @@ -31,7 +31,7 @@ import ctools class cscaldb(ctools.cscript): """ Shows the content of the ctools calibration database. - + The ``cscaldb`` script writes the content of the calibration database into the ``cscaldb.log`` log file. If the ``debug`` parameter is set to ``yes`` the calibration database is also logged in the console. @@ -41,7 +41,7 @@ class cscaldb(ctools.cscript): def __init__(self, *argv): """ Constructor. - + Parameters ---------- argv : list of str @@ -132,7 +132,7 @@ class cscaldb(ctools.cscript): name = cal[5:istop] if names.count(name) == 0: names.append(name) - + # Sort response names names.sort() @@ -197,22 +197,6 @@ class cscaldb(ctools.cscript): # Return return - def execute(self): - """ - Execute the script. - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/csebins.py b/cscripts/csebins.py index 2cbb828..ba3b2ee 100755 --- a/cscripts/csebins.py +++ b/cscripts/csebins.py @@ -302,25 +302,6 @@ class csebins(ctools.cscript): # Return return self._ebounds - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the scrip - self.run() - - # Save energy boundaries - self.save() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/csfindobs.py b/cscripts/csfindobs.py index 23014cb..3addbe4 100755 --- a/cscripts/csfindobs.py +++ b/cscripts/csfindobs.py @@ -231,25 +231,6 @@ class csfindobs(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save residual map - self.save() - - # Return - return - def save(self): """ Save runlist diff --git a/cscripts/csiactcopy.py b/cscripts/csiactcopy.py index 7b84b1d..c1f0bf9 100755 --- a/cscripts/csiactcopy.py +++ b/cscripts/csiactcopy.py @@ -736,23 +736,6 @@ class csiactcopy(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Return - return - - # ======================== # # Main routine entry point # # ======================== # diff --git a/cscripts/csiactdata.py b/cscripts/csiactdata.py index a48dd44..bfc8aae 100755 --- a/cscripts/csiactdata.py +++ b/cscripts/csiactdata.py @@ -177,22 +177,6 @@ class csiactdata(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Return - return - def names(self): """ Return available FITS production names diff --git a/cscripts/csiactobs.py b/cscripts/csiactobs.py index 3642d80..2ca8437 100755 --- a/cscripts/csiactobs.py +++ b/cscripts/csiactobs.py @@ -774,25 +774,6 @@ class csiactobs(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save residual map - self.save() - - # Return - return - def save(self): """ Save observation definition and model definition XML file diff --git a/cscripts/cslightcrv.py b/cscripts/cslightcrv.py index e5ff788..a44861b 100755 --- a/cscripts/cslightcrv.py +++ b/cscripts/cslightcrv.py @@ -614,25 +614,6 @@ class cslightcrv(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save lightcurve - self.save() - - # Return - return - def save(self): """ Save light curve diff --git a/cscripts/csmodelinfo.py b/cscripts/csmodelinfo.py index 9d45f1f..573cc7f 100755 --- a/cscripts/csmodelinfo.py +++ b/cscripts/csmodelinfo.py @@ -292,25 +292,6 @@ class csmodelinfo(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save ds9 file if required - self.save() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/csmodelmerge.py b/cscripts/csmodelmerge.py index 151e4e0..98ab11a 100755 --- a/cscripts/csmodelmerge.py +++ b/cscripts/csmodelmerge.py @@ -187,25 +187,6 @@ class csmodelmerge(ctools.cscript): # Return return - - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save ds9 file if required - self.save() - - # Return - return # ======================== # diff --git a/cscripts/csmodelselect.py b/cscripts/csmodelselect.py index e38e465..2ad3c84 100755 --- a/cscripts/csmodelselect.py +++ b/cscripts/csmodelselect.py @@ -295,25 +295,6 @@ class csmodelselect(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save model file if required - self.save() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/csmodelsois.py b/cscripts/csmodelsois.py index 37eacbb..a3745a3 100755 --- a/cscripts/csmodelsois.py +++ b/cscripts/csmodelsois.py @@ -194,25 +194,6 @@ class csmodelsois(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save model - self.save() - - # Return - return - def save(self): """ Save the cube and optionally the updated XML model file diff --git a/cscripts/csobs2caldb.py b/cscripts/csobs2caldb.py index 4daa71e..2882da5 100755 --- a/cscripts/csobs2caldb.py +++ b/cscripts/csobs2caldb.py @@ -392,25 +392,6 @@ class csobs2caldb(ctools.cscript): # Return return - - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save to disk - self.save() - - # Return - return # ======================== # diff --git a/cscripts/csobsdef.py b/cscripts/csobsdef.py index 05b3cd4..f1a2d7e 100755 --- a/cscripts/csobsdef.py +++ b/cscripts/csobsdef.py @@ -370,25 +370,6 @@ class csobsdef(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save observation definition file - self.save() - - # Return - return - def obs(self): """ Returns observation container diff --git a/cscripts/csobsinfo.py b/cscripts/csobsinfo.py index 000128d..2418464 100755 --- a/cscripts/csobsinfo.py +++ b/cscripts/csobsinfo.py @@ -390,25 +390,6 @@ class csobsinfo(ctools.cscript): Return good time intervals """ return self._gti - - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save ds9 file if required - self.save() - - # Return - return # ======================== # diff --git a/cscripts/csobsselect.py b/cscripts/csobsselect.py index f33bc56..2460262 100755 --- a/cscripts/csobsselect.py +++ b/cscripts/csobsselect.py @@ -335,25 +335,6 @@ class csobsselect(ctools.cscript): """ return self._obs - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save observation definition file - self.save() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/csphagen.py b/cscripts/csphagen.py index 8843252..dc59eef 100755 --- a/cscripts/csphagen.py +++ b/cscripts/csphagen.py @@ -330,25 +330,6 @@ class csphagen(ctools.cscript): """ return self._outobs - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save result - self.save() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/csphasecrv.py b/cscripts/csphasecrv.py index 7fc0b75..967d3b2 100755 --- a/cscripts/csphasecrv.py +++ b/cscripts/csphasecrv.py @@ -408,25 +408,6 @@ class csphasecrv(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save fitted models - self.save() - - # Return - return - def save(self): """ Saves results to fits and XML diff --git a/cscripts/cspull.py b/cscripts/cspull.py index 14072b5..775da83 100755 --- a/cscripts/cspull.py +++ b/cscripts/cspull.py @@ -311,22 +311,6 @@ class cspull(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Return - return - def models(self, models): """ Set model diff --git a/cscripts/csresmap.py b/cscripts/csresmap.py index 0020d3d..c6c3ca6 100755 --- a/cscripts/csresmap.py +++ b/cscripts/csresmap.py @@ -285,25 +285,6 @@ class csresmap(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save residual map - self.save() - - # Return - return - def save(self): """ Save residual map diff --git a/cscripts/csroot2caldb.py b/cscripts/csroot2caldb.py index 42281f5..02f2897 100755 --- a/cscripts/csroot2caldb.py +++ b/cscripts/csroot2caldb.py @@ -1777,22 +1777,6 @@ class csroot2caldb(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/cssens.py b/cscripts/cssens.py index e615d47..6aa8e82 100755 --- a/cscripts/cssens.py +++ b/cscripts/cssens.py @@ -642,22 +642,6 @@ class cssens(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/csspec.py b/cscripts/csspec.py index 1aa5aa8..d7e0df0 100755 --- a/cscripts/csspec.py +++ b/cscripts/csspec.py @@ -889,25 +889,6 @@ class csspec(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save spectrum - self.save() - - # Return - return - def save(self): """ Save spectrum diff --git a/cscripts/cssrcdetect.py b/cscripts/cssrcdetect.py index 8ebc8a3..60d2e68 100755 --- a/cscripts/cssrcdetect.py +++ b/cscripts/cssrcdetect.py @@ -464,25 +464,6 @@ class cssrcdetect(ctools.cscript): """ return self._models - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save observation definition file - self.save() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/cstsdist.py b/cscripts/cstsdist.py index 6657c72..4954a04 100755 --- a/cscripts/cstsdist.py +++ b/cscripts/cstsdist.py @@ -279,22 +279,6 @@ class cstsdist(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/cstsmapmerge.py b/cscripts/cstsmapmerge.py index d385ee6..ff9dc78 100755 --- a/cscripts/cstsmapmerge.py +++ b/cscripts/cstsmapmerge.py @@ -448,25 +448,6 @@ class cstsmapmerge(ctools.cscript): # Return return - - def execute(self): - """ - Execute the script. - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save TS map if required - self.save() - - # Return - return # ======================== # diff --git a/cscripts/cstsmapsplit.py b/cscripts/cstsmapsplit.py index 3a17b61..ad8c322 100755 --- a/cscripts/cstsmapsplit.py +++ b/cscripts/cstsmapsplit.py @@ -278,25 +278,6 @@ class cstsmapsplit(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save results - self.save() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/csviscube.py b/cscripts/csviscube.py index f1a0f77..ba50d24 100755 --- a/cscripts/csviscube.py +++ b/cscripts/csviscube.py @@ -512,25 +512,6 @@ class csviscube(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Save the cube - self.save() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/cscripts/csworkflow.py b/cscripts/csworkflow.py index 76a23d2..a777c9f 100755 --- a/cscripts/csworkflow.py +++ b/cscripts/csworkflow.py @@ -353,22 +353,6 @@ class csworkflow(ctools.cscript): # Return return - def execute(self): - """ - Execute the script - """ - # Open logfile - self.logFileOpen() - - # Read ahead output parameters - self._read_ahead(True) - - # Run the script - self.run() - - # Return - return - # ======================== # # Main routine entry point # diff --git a/pyext/ctool.i b/pyext/ctool.i index 3eadb0e..a7cfc9b 100644 --- a/pyext/ctool.i +++ b/pyext/ctool.i @@ -294,6 +294,14 @@ def _pardict(self, *args): self[key] = args[0][key] else: raise TypeError('pardict() takes 0 or 1 arguments (%d given)' % len(args)) -ctool.pardict = _pardict +ctool.pardict = _pardict cscript.pardict = _pardict + +# Execute the script +def _execute(self): + self.logFileOpen() + self._read_ahead(True) + self.run() + self.save() +cscript.execute = _execute %} -- libgit2 0.21.4