[SCM] Control pipeline recipes from the European Southern Observatory branch, debian, updated. upstream/0.3.5.1-36-g63ff8c5

Ole Streicher debian at liska.ath.cx
Fri Sep 14 13:16:29 UTC 2012


The following commit has been merged in the debian branch:
commit 63ff8c5a6f719f869d92950b72327d208e54d753
Author: Ole Streicher <debian at liska.ath.cx>
Date:   Fri Sep 14 15:16:01 2012 +0200

    Updated for new upstream release 0.3.7

diff --git a/debian/changelog b/debian/changelog
index 8a60d20..fb22f0f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+python-cpl (0.3.7-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Ole Streicher <debian at liska.ath.cx>  Fri, 14 Sep 2012 14:58:46 +0200
+
 python-cpl (0.3.6-1) unstable; urgency=low
 
   * New upstream release
diff --git a/debian/patches/disable_crash_tests.patch b/debian/patches/disable_crash_tests.patch
index 86a02f4..b482294 100644
--- a/debian/patches/disable_crash_tests.patch
+++ b/debian/patches/disable_crash_tests.patch
@@ -6,7 +6,7 @@ Description: On armel, mips and mipsel, the tests that try to crash the recipe
 Forwarded: not-needed
 --- a/test/TestRecipe.py
 +++ b/test/TestRecipe.py
-@@ -411,17 +411,17 @@
+@@ -413,17 +413,17 @@
          self.recipe.tag = 'some_unknown_tag'
          self.assertRaises(cpl.CplError, self.recipe, self.raw_frame)
  
diff --git a/debian/patches/set-default-plugin-path.patch b/debian/patches/set-default-plugin-path.patch
index f4701d6..a942625 100644
--- a/debian/patches/set-default-plugin-path.patch
+++ b/debian/patches/set-default-plugin-path.patch
@@ -3,8 +3,8 @@ Description: Set the default plugin path to the one where recipes are
  installed in Debian.
 --- a/cpl/recipes.py
 +++ b/cpl/recipes.py
-@@ -37,7 +37,7 @@
-     version: (versionnumber, versionstring) pair
+@@ -40,7 +40,7 @@
+       Standard is 0: nothing dumped.
      '''
  
 -    path = [ '.' ]
diff --git a/test/TestRecipe.py b/test/TestRecipe.py
index 6044de7..22cac17 100644
--- a/test/TestRecipe.py
+++ b/test/TestRecipe.py
@@ -8,6 +8,9 @@ import numpy
 import pyfits
 import cpl
 
+recipe_name = 'rtest'
+raw_tag = 'RRRECIPE_DOCATG_RAW'
+
 class CplTestCase(unittest.TestCase):
     def setUp(self):
         cpl.Recipe.path = os.path.dirname(os.path.abspath(__file__))
@@ -16,16 +19,15 @@ class RecipeTestCase(CplTestCase):
     def setUp(self):
         CplTestCase.setUp(self)
         self.temp_dir = tempfile.mkdtemp()
-        self.recipe = cpl.Recipe('rrrecipe')
+        self.recipe = cpl.Recipe(recipe_name)
         self.recipe.temp_dir = self.temp_dir
-        self.recipe.tag = 'RRRECIPE_DOCATG_RAW'
+        self.recipe.tag = raw_tag
         self.image_size = (16, 16)
         self.raw_frame = pyfits.HDUList([
                 pyfits.PrimaryHDU(numpy.random.random_integers(0, 65000,
                                                                self.image_size))])
         self.raw_frame[0].header.update('HIERARCH ESO DET DIT', 0.0)
-        self.raw_frame[0].header.update('HIERARCH ESO PRO CATG', 
-                                        'RRRECIPE_DOCATG_RAW')
+        self.raw_frame[0].header.update('HIERARCH ESO PRO CATG', raw_tag)
 
     def tearDown(self):
         shutil.rmtree(self.temp_dir)
@@ -36,16 +38,16 @@ class RecipeStatic(CplTestCase):
         l = cpl.Recipe.list()
         self.assertTrue(isinstance(l, list))
         self.assertEqual(len(l), 1)
-        self.assertEqual(l[0], ('rrrecipe', ['0.0.1']))
+        self.assertEqual(l[0], (recipe_name, ['0.0.1']))
 
     def test_create_recipe(self):
         '''Create a recipe specified by its name'''
-        recipe = cpl.Recipe('rrrecipe')
+        recipe = cpl.Recipe(recipe_name)
         self.assertTrue(isinstance(recipe, cpl.Recipe))
 
     def test_create_recipe_version(self):
         '''Create a recipe specified by its name and version'''
-        recipe = cpl.Recipe('rrrecipe', version = '0.0.1')
+        recipe = cpl.Recipe(recipe_name, version = '0.0.1')
         self.assertTrue(isinstance(recipe, cpl.Recipe))        
 
     def test_create_recipe_wrong_name(self):
@@ -54,34 +56,34 @@ class RecipeStatic(CplTestCase):
 
     def test_create_recipe_wrong_version(self):
         '''Create a recipe specified by a wrong version'''
-        self.assertRaises(IOError, cpl.Recipe, 'rrrecipe', version='0.0.10')
+        self.assertRaises(IOError, cpl.Recipe, recipe_name, version='0.0.10')
 
     def test_create_recipe_filename(self):
         '''Create a recipe specified by a the name and the filename'''
-        recipe = cpl.Recipe('rrrecipe', filename = os.path.join(
+        recipe = cpl.Recipe(recipe_name, filename = os.path.join(
                 os.path.dirname(os.path.abspath(__file__)),
-                'iiinstrumentp', 'recipes', '.libs', 'rrrecipe.so'))
+                'iiinstrumentp', 'recipes', '.libs', 'rtest.so'))
         self.assertTrue(isinstance(recipe, cpl.Recipe))
 
     def test_create_recipe_wrong_filename(self):
         '''Create a recipe specified by a wrong filename'''
-        self.assertRaises(IOError, cpl.Recipe, 'rrrecipe', 
+        self.assertRaises(IOError, cpl.Recipe, recipe_name, 
                           filename = os.path.join(
                 os.path.dirname(os.path.abspath(__file__)),
-                'iiinstrumentp', 'recipes', '.libs', 'rrrecipe.o'))
+                'iiinstrumentp', 'recipes', '.libs', 'rtest.o'))
 
 class RecipeCommon(RecipeTestCase):
     def test_name(self):
         '''Recipe name'''
-        self.assertEqual(self.recipe.__name__, 'rrrecipe')
+        self.assertEqual(self.recipe.__name__, recipe_name)
 
     def test_author(self):
         '''Author attribute'''
-        self.assertEqual(self.recipe.__author__, 'Firstname Lastname')
+        self.assertEqual(self.recipe.__author__, 'Ole Streicher')
 
     def test_email(self):
         '''Author attribute'''
-        self.assertEqual(self.recipe.__email__, 'flastname at eso.org')
+        self.assertEqual(self.recipe.__email__, 'python-cpl at liska.ath.cx')
 
     def test_description(self):
         '''Synopsis and description'''
@@ -101,7 +103,7 @@ class RecipeParams(RecipeTestCase):
         self.assertTrue(isinstance(self.recipe.param.stropt, cpl.Parameter))
         self.assertEqual(self.recipe.param.stropt.name, 'stropt')
         self.assertEqual(self.recipe.param.stropt.context, 
-                         'iiinstrument.rrrecipe')
+                         'iiinstrument.rtest')
         self.assertEqual(self.recipe.param.stropt.default, None)
         self.assertEqual(self.recipe.param.stropt.value, None)
         self.assertEqual(self.recipe.param.stropt.range, None)
@@ -177,14 +179,14 @@ class RecipeParams(RecipeTestCase):
         self.assertEqual(self.recipe.param.boolopt, 
                          self.recipe.param['boolopt'])
         self.assertEqual(self.recipe.param.boolopt, 
-                         self.recipe.param['iiinstrument.rrrecipe.bool_option'])
+                         self.recipe.param['iiinstrument.rtest.bool_option'])
 
     def test_dotted_par(self):
         '''Use a parameter that has a dot in its alias'''
         self.assertEqual(self.recipe.param.dot_opt, 
                          self.recipe.param['dot.opt'])
         self.assertEqual(self.recipe.param.dot_opt, 
-                         self.recipe.param['iiinstrument.rrrecipe.dotted.opt'])
+                         self.recipe.param['iiinstrument.rtest.dotted.opt'])
 
     def test_iterate(self):
         '''Iteration over all parameters'''
@@ -206,9 +208,9 @@ class RecipeParams(RecipeTestCase):
         self.assertEqual(self.recipe.param.boolopt.value, False)
 
         # Check that we can assign a dictionary with the long names
-        self.recipe.param = { 'iiinstrument.rrrecipe.string_option':'dless', 
-                      'iiinstrument.rrrecipe.float_option':1.5, 
-                      'iiinstrument.rrrecipe.bool_option':True }
+        self.recipe.param = { 'iiinstrument.rtest.string_option':'dless', 
+                      'iiinstrument.rtest.float_option':1.5, 
+                      'iiinstrument.rtest.bool_option':True }
         self.assertEqual(self.recipe.param.stropt.value, 'dless')
         self.assertEqual(self.recipe.param.floatopt.value, 1.5)
         self.assertEqual(self.recipe.param.boolopt.value, True)
@@ -283,7 +285,7 @@ class RecipeExec(RecipeTestCase):
     def test_frames_keyword_dict(self):
         '''Raw and calibration frames specified as keyword dict'''
         self.recipe.tag = None
-        res = self.recipe(raw_RRRECIPE_DOCATG_RAW = self.raw_frame, 
+        res = self.recipe(raw = {'RRRECIPE_DOCATG_RAW': self.raw_frame },
                           calib = { 'FLAT':self.flat_frame })
         self.assertTrue(isinstance(res, cpl.Result))
         self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, pyfits.HDUList))
@@ -302,13 +304,13 @@ class RecipeExec(RecipeTestCase):
         '''The 'tag' parameter'''
         self.recipe.tag = None
         self.recipe.calib.FLAT = self.flat_frame
-        res = self.recipe(self.raw_frame, tag = 'RRRECIPE_DOCATG_RAW')
+        res = self.recipe(self.raw_frame, tag = raw_tag)
         self.assertTrue(isinstance(res, cpl.Result))
         self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, pyfits.HDUList))
 
     def test_frames_tag_attribute(self):
         '''The 'tag' attribute'''
-        self.recipe.tag = 'RRRECIPE_DOCATG_RAW'
+        self.recipe.tag = raw_tag
         res = self.recipe(self.raw_frame)
         self.assertTrue(isinstance(res, cpl.Result))
         self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, pyfits.HDUList))
@@ -337,7 +339,7 @@ class RecipeExec(RecipeTestCase):
         self.assertTrue(isinstance(res, cpl.Result))
         self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, str))
         self.assertEqual(os.path.basename(res.THE_PRO_CATG_VALUE), 
-                         'rrrecipe.fits')
+                         'rtest.fits')
         self.assertTrue(os.path.isdir(output_dir))
         self.assertTrue(os.path.isfile(res.THE_PRO_CATG_VALUE))
         hdu = pyfits.open(res.THE_PRO_CATG_VALUE)
@@ -353,7 +355,7 @@ class RecipeExec(RecipeTestCase):
         self.assertTrue(isinstance(res, cpl.Result))
         self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, str))
         self.assertEqual(os.path.basename(res.THE_PRO_CATG_VALUE), 
-                         'rrrecipe.fits')
+                         'rtest.fits')
         self.assertTrue(os.path.isfile(res.THE_PRO_CATG_VALUE))
         hdu = pyfits.open(res.THE_PRO_CATG_VALUE)
         self.assertTrue(isinstance(hdu, pyfits.HDUList))
@@ -461,7 +463,7 @@ class RecipeExec(RecipeTestCase):
 
     def test_md5sum_result(self):
         '''MD5sum of the result file'''
-        self.recipe.tag = 'RRRECIPE_DOCATG_RAW'
+        self.recipe.tag = raw_tag
         res = self.recipe(self.raw_frame)
         key = 'DATAMD5'
         md5sum = res.THE_PRO_CATG_VALUE[0].header[key]
@@ -471,7 +473,7 @@ class RecipeExec(RecipeTestCase):
 
     def test_md5sum_calib(self):
         '''Created MD5sum for a HDUList calib file'''
-        self.recipe.tag = 'RRRECIPE_DOCATG_RAW'
+        self.recipe.tag = raw_tag
         self.recipe.calib.FLAT = self.flat_frame
         res = self.recipe(self.raw_frame)
         key = 'HIERARCH ESO PRO REC1 CAL1 DATAMD5'
@@ -546,13 +548,13 @@ class RecipeLog(RecipeTestCase):
     def setUp(self):
         RecipeTestCase.setUp(self)
         self.handler = RecipeLog.THandler()
-        logging.getLogger('cpl.rrrecipe').addHandler(self.handler)
+        logging.getLogger('cpl.rtest').addHandler(self.handler)
         self.other_handler = RecipeLog.THandler()
         logging.getLogger('othername').addHandler(self.other_handler)
 
     def tearDown(self):
         RecipeTestCase.tearDown(self)
-        logging.getLogger('cpl.rrrecipe').removeHandler(self.handler)
+        logging.getLogger('cpl.rtest').removeHandler(self.handler)
         logging.getLogger('othername').removeHandler(self.other_handler)
 
     class THandler(logging.Handler):
@@ -586,12 +588,12 @@ class RecipeLog(RecipeTestCase):
             lognames.add(r.name)
         # Check that we had at least one expected entry
         self.assertTrue('cpl_dfs_product_save' in funcnames)
-        self.assertTrue('cpl.rrrecipe.cpl_dfs_product_save' in lognames)
+        self.assertTrue('cpl.rtest.cpl_dfs_product_save' in lognames)
         
     def test_logging_INFO(self):
         '''Filtering INFO messages'''
         self.handler.clear()
-        logging.getLogger('cpl.rrrecipe').setLevel(logging.INFO)
+        logging.getLogger('cpl.rtest').setLevel(logging.INFO)
         self.recipe(self.raw_frame)
         # check that the logs are not empty
         self.assertNotEqual(len(self.handler.logs), 0)
@@ -599,7 +601,7 @@ class RecipeLog(RecipeTestCase):
     def test_logging_WARN(self):
         '''Filtering WARN messages'''
         self.handler.clear()
-        logging.getLogger('cpl.rrrecipe').setLevel(logging.WARN)
+        logging.getLogger('cpl.rtest').setLevel(logging.WARN)
         self.recipe(self.raw_frame)
         # check that the logs are not empty
         self.assertNotEqual(len(self.handler.logs), 0)
@@ -608,7 +610,7 @@ class RecipeLog(RecipeTestCase):
         '''Filtering of error messages'''
         # There is no error msg written by the recipe, so it should be empty.
         self.handler.clear()
-        logging.getLogger('cpl.rrrecipe').setLevel(logging.ERROR)
+        logging.getLogger('cpl.rtest').setLevel(logging.ERROR)
         self.recipe(self.raw_frame)
         self.assertEqual(len(self.handler.logs), 0)
 
diff --git a/test/iiinstrumentp/recipes/Makefile.am b/test/iiinstrumentp/recipes/Makefile.am
index b240fe9..1186b4d 100644
--- a/test/iiinstrumentp/recipes/Makefile.am
+++ b/test/iiinstrumentp/recipes/Makefile.am
@@ -25,9 +25,9 @@ INCLUDES = $(all_includes)
 
 noinst_HEADERS = 
 
-plugin_LTLIBRARIES = rrrecipe.la 
+plugin_LTLIBRARIES = rtest.la 
 
-rrrecipe_la_SOURCES = rrrecipe.c 
-rrrecipe_la_LIBADD = $(LIBCPLDFS) $(LIBIIINSTRUMENT)
-rrrecipe_la_LDFLAGS = -module -avoid-version
-rrrecipe_la_DEPENDENCIES = $(LIBIIINSTRUMENT)
+rtest_la_SOURCES = rtest.c 
+rtest_la_LIBADD = $(LIBCPLDFS) $(LIBIIINSTRUMENT)
+rtest_la_LDFLAGS = -module -avoid-version
+rtest_la_DEPENDENCIES = $(LIBIIINSTRUMENT)
diff --git a/test/iiinstrumentp/recipes/rrrecipe.c b/test/iiinstrumentp/recipes/rtest.c
similarity index 60%
rename from test/iiinstrumentp/recipes/rrrecipe.c
rename to test/iiinstrumentp/recipes/rtest.c
index e6c0147..3632f20 100644
--- a/test/iiinstrumentp/recipes/rrrecipe.c
+++ b/test/iiinstrumentp/recipes/rtest.c
@@ -1,7 +1,8 @@
-/* $Id: rrrecipe.c,v 1.28 2007/07/30 07:08:59 llundin Exp $
+/* $Id: rtest.c,v 1.28 2007/07/30 07:08:59 llundin Exp $
  *
  * This file is part of the IIINSTRUMENT Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
+ * Copyright (C) 2011,2012 Ole Streicher
  *
  * 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
@@ -18,19 +19,15 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: llundin $
- * $Date: 2007/07/30 07:08:59 $
- * $Revision: 1.28 $
- * $Name:  $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 /*-----------------------------------------------------------------------------
 				Includes
@@ -46,25 +43,17 @@
 			    Private function prototypes
  -----------------------------------------------------------------------------*/
 
-static int rrrecipe_create(cpl_plugin *);
-static int rrrecipe_exec(cpl_plugin *);
-static int rrrecipe_destroy(cpl_plugin *);
-static int rrrecipe(cpl_frameset *, const cpl_parameterlist *);
+static int rtest_create(cpl_plugin *);
+static int rtest_exec(cpl_plugin *);
+static int rtest_destroy(cpl_plugin *);
+static int rtest(cpl_frameset *, const cpl_parameterlist *);
 
 /*-----------------------------------------------------------------------------
 			    Static variables
  -----------------------------------------------------------------------------*/
 
-static char rrrecipe_description[] =
-"This example text is used to describe the recipe.\n"
-"The description should include the required FITS-files and\n"
-"their associated tags, e.g.\n"
-"IIINSTRUMENT-RRRECIPE-raw-file.fits " RRRECIPE_RAW "\n"
-"and any optional files, e.g.\n"
-"IIINSTRUMENT-RRRECIPE-flat-file.fits " IIINSTRUMENT_CALIB_FLAT "\n"
-"\n"
-"Additionally, it should describe functionality of the expected output."
-"\n";
+static char rtest_description[] =
+"Recipe to test CPL frameworks like esorex or python-cpl.\n";
 
 /*-----------------------------------------------------------------------------
 				Function code
@@ -90,15 +79,15 @@ int cpl_plugin_get_info(cpl_pluginlist * list)
 		    CPL_PLUGIN_API,
 		    IIINSTRUMENT_BINARY_VERSION,
 		    CPL_PLUGIN_TYPE_RECIPE,
-		    "rrrecipe",
-		    "Short description of rrrecipe",
-		    rrrecipe_description,
-		    "Firstname Lastname",
-		    PACKAGE_BUGREPORT,
+		    "rtest",
+		    "Framework test recipe",
+		    rtest_description,
+		    "Ole Streicher",
+		    "python-cpl at liska.ath.cx",
 		    iiinstrument_get_license(),
-		    rrrecipe_create,
-		    rrrecipe_exec,
-		    rrrecipe_destroy)) {
+		    rtest_create,
+		    rtest_exec,
+		    rtest_destroy)) {
 	cpl_msg_error(cpl_func, "Plugin initialization failed");
 	(void)cpl_error_set_where(cpl_func);
 	return 1;
@@ -122,31 +111,13 @@ int cpl_plugin_get_info(cpl_pluginlist * list)
   Defining the command-line/configuration parameters for the recipe.
  */
 /*----------------------------------------------------------------------------*/
-static int rrrecipe_create(cpl_plugin * plugin)
+static int rtest_create(cpl_plugin * plugin)
 {
-    cpl_recipe    * recipe;
-    cpl_parameter * p;
-
-    /* Do not create the recipe if an error code is already set */
-    if (cpl_error_get_code() != CPL_ERROR_NONE) {
-	cpl_msg_error(cpl_func, "%s():%d: An error is already set: %s",
-		      cpl_func, __LINE__, cpl_error_get_where());
-	return (int)cpl_error_get_code();
-    }
+    cpl_ensure_code((plugin != NULL), CPL_ERROR_NULL_INPUT);
+    cpl_ensure_code((cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE),
+		    CPL_ERROR_TYPE_MISMATCH);
 
-    if (plugin == NULL) {
-	cpl_msg_error(cpl_func, "Null plugin");
-	cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
-    }
-
-    /* Verify plugin type */
-    if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
-	cpl_msg_error(cpl_func, "Plugin is not a recipe");
-	cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
-    }
-
-    /* Get the recipe */
-    recipe = (cpl_recipe *)plugin;
+    cpl_recipe *recipe = (cpl_recipe *)plugin;
 
     /* Create the parameters list in the cpl_recipe object */
     recipe->parameters = cpl_parameterlist_new();
@@ -156,64 +127,87 @@ static int rrrecipe_create(cpl_plugin * plugin)
     }
 
     /* Fill the parameters list */
+    cpl_parameter * p;
     /* --stropt */
-    p = cpl_parameter_new_value("iiinstrument.rrrecipe.string_option",
-	    CPL_TYPE_STRING, "the string option", "iiinstrument.rrrecipe",NULL);
+    p = cpl_parameter_new_value("iiinstrument.rtest.string_option",
+	    CPL_TYPE_STRING,
+	    "A string option; saved as ESO QC STROPT",
+	    "iiinstrument.rtest",NULL);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "stropt");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --boolopt */
-    p = cpl_parameter_new_value("iiinstrument.rrrecipe.bool_option",
-	    CPL_TYPE_BOOL, "a flag", "iiinstrument.rrrecipe", TRUE);
+    p = cpl_parameter_new_value("iiinstrument.rtest.bool_option",
+	    CPL_TYPE_BOOL,
+	    "A flag; saved as ESO QC BOOLOPT",
+	    "iiinstrument.rtest", TRUE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "boolopt");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --floatopt */
-    p = cpl_parameter_new_value("iiinstrument.rrrecipe.float_option",
-	    CPL_TYPE_DOUBLE, "a flag", "iiinstrument.rrrecipe", 0.1);
+    p = cpl_parameter_new_value("iiinstrument.rtest.float_option",
+	    CPL_TYPE_DOUBLE,
+	    "A double option; saved as ESO QC FLOATOPT",
+	    "iiinstrument.rtest", 0.1);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "floatopt");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --inttopt */
-    p = cpl_parameter_new_value("iiinstrument.rrrecipe.int_option",
-	    CPL_TYPE_INT, "a flag", "iiinstrument.rrrecipe", 2);
+    p = cpl_parameter_new_value("iiinstrument.rtest.int_option",
+	    CPL_TYPE_INT,
+	    "An interger; saved as ESO QC INTOPT",
+	    "iiinstrument.rtest", 2);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "intopt");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --enumopt */
-    p = cpl_parameter_new_enum("iiinstrument.rrrecipe.enum_option",
-	    CPL_TYPE_STRING, "the string option", "iiinstrument.rrrecipe",
-			       "first", 3, "first", "second", "third");
+    p = cpl_parameter_new_enum("iiinstrument.rtest.enum_option",
+	    CPL_TYPE_STRING,
+	    "An enumeration option, saved as ESO QC ENUMOPT",
+	    "iiinstrument.rtest", "first", 3, "first", "second", "third");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "enumopt");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --rangeopt */
-    p = cpl_parameter_new_range("iiinstrument.rrrecipe.range_option",
-	    CPL_TYPE_DOUBLE, "a flag", "iiinstrument.rrrecipe", 0.1, -0.5, 0.5);
+    p = cpl_parameter_new_range("iiinstrument.rtest.range_option",
+	    CPL_TYPE_DOUBLE,
+	    "A double option with a range, saved as ESO QC RANGEOPT",
+	    "iiinstrument.rtest", 0.1, -0.5, 0.5);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "rangeopt");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --dot.opt */
-    p = cpl_parameter_new_value("iiinstrument.rrrecipe.dotted.opt",
-	    CPL_TYPE_INT, "a flag", "iiinstrument.rrrecipe", 0);
+    p = cpl_parameter_new_value("iiinstrument.rtest.dotted.opt",
+	    CPL_TYPE_INT,
+	    "An (integer) option with a dot in its name",
+	    "iiinstrument.rtest", 0);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dot.opt");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --crashing */
-    p = cpl_parameter_new_enum("iiinstrument.rrrecipe.crashing",
-	  CPL_TYPE_STRING, "Crash the recipe?", "iiinstrument.rrrecipe",
+    p = cpl_parameter_new_enum("iiinstrument.rtest.crashing",
+	  CPL_TYPE_STRING, "Crash the recipe?", "iiinstrument.rtest",
 			       "no", 3, "no", "free", "segfault");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "crashing");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
+    /* --sleep */
+    p = cpl_parameter_new_value("iiinstrument.rtest.sleep",
+	    CPL_TYPE_DOUBLE,
+	    "Simulate some computing by sleeping for specified time [seconds]",
+	    "iiinstrument.rtest", 0.1);
+    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sleep");
+    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
+    cpl_parameterlist_append(recipe->parameters, p);
+
     return 0;
 }
 
@@ -224,58 +218,24 @@ static int rrrecipe_create(cpl_plugin * plugin)
   @return   0 if everything is ok
  */
 /*----------------------------------------------------------------------------*/
-static int rrrecipe_exec(cpl_plugin * plugin)
+static int rtest_exec(cpl_plugin * plugin)
 {
+    cpl_ensure_code((plugin != NULL), CPL_ERROR_NULL_INPUT);
+    cpl_ensure_code((cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE),
+		    CPL_ERROR_TYPE_MISMATCH);
 
-    cpl_recipe * recipe;
-    int recipe_status;
-    cpl_errorstate initial_errorstate = cpl_errorstate_get();
-
-    /* Return immediately if an error code is already set */
-    if (cpl_error_get_code() != CPL_ERROR_NONE) {
-	cpl_msg_error(cpl_func, "%s():%d: An error is already set: %s",
-		      cpl_func, __LINE__, cpl_error_get_where());
-	return (int)cpl_error_get_code();
-    }
-
-    if (plugin == NULL) {
-	cpl_msg_error(cpl_func, "Null plugin");
-	cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
-    }
-
-    /* Verify plugin type */
-    if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
-	cpl_msg_error(cpl_func, "Plugin is not a recipe");
-	cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
-    }
-
-    /* Get the recipe */
-    recipe = (cpl_recipe *)plugin;
+    cpl_recipe *recipe = (cpl_recipe *)plugin;
 
-    /* Verify parameter and frame lists */
-    if (recipe->parameters == NULL) {
-	cpl_msg_error(cpl_func, "Recipe invoked with NULL parameter list");
-	cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
-    }
-    if (recipe->frames == NULL) {
-	cpl_msg_error(cpl_func, "Recipe invoked with NULL frame set");
-	cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
-    }
+    cpl_ensure_code((recipe->parameters != NULL), (int)CPL_ERROR_NULL_INPUT);
+    cpl_ensure_code((recipe->frames != NULL), (int)CPL_ERROR_NULL_INPUT);
 
-    /* Invoke the recipe */
-    recipe_status = rrrecipe(recipe->frames, recipe->parameters);
+    int recipe_status = rtest(recipe->frames, recipe->parameters);
 
     /* Ensure DFS-compliance of the products */
     if (cpl_dfs_update_product_header(recipe->frames)) {
 	if (!recipe_status) recipe_status = (int)cpl_error_get_code();
     }
 
-    if (!cpl_errorstate_is_equal(initial_errorstate)) {
-	/* Dump the error history since recipe execution start.
-	   At this point the recipe cannot recover from the error */
-	cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
-    }
-
     return recipe_status;
 }
 
@@ -286,24 +246,13 @@ static int rrrecipe_exec(cpl_plugin * plugin)
   @return   0 if everything is ok
  */
 /*----------------------------------------------------------------------------*/
-static int rrrecipe_destroy(cpl_plugin * plugin)
+static int rtest_destroy(cpl_plugin * plugin)
 {
-    cpl_recipe * recipe;
-
-    if (plugin == NULL) {
-	cpl_msg_error(cpl_func, "Null plugin");
-	cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
-    }
-
-    /* Verify plugin type */
-    if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
-	cpl_msg_error(cpl_func, "Plugin is not a recipe");
-	cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
-    }
-
-    /* Get the recipe */
-    recipe = (cpl_recipe *)plugin;
+    cpl_ensure_code((plugin != NULL), CPL_ERROR_NULL_INPUT);
+    cpl_ensure_code((cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE),
+		    CPL_ERROR_TYPE_MISMATCH);
 
+    cpl_recipe *recipe = (cpl_recipe *)plugin;
     cpl_parameterlist_delete(recipe->parameters);
 
     return 0;
@@ -317,58 +266,55 @@ static int rrrecipe_destroy(cpl_plugin * plugin)
   @return   0 if everything is ok
  */
 /*----------------------------------------------------------------------------*/
-static int rrrecipe(cpl_frameset            * frameset,
+static int rtest(cpl_frameset            * frameset,
 		    const cpl_parameterlist * parlist)
 {
-    const cpl_parameter *   param;
-    const cpl_frame     *   rawframe;
-    const cpl_frame     *   flat;
-    double                  qc_param;
-    cpl_propertylist    *   plist;
-    cpl_propertylist    *   qclist;
-    cpl_image           *   image;
-
     /* Use the errorstate to detect an error in a function that does not
        return an error code. */
-    cpl_errorstate          prestate = cpl_errorstate_get();
+    cpl_errorstate prestate = cpl_errorstate_get();
 
-    /* HOW TO RETRIEVE INPUT PARAMETERS */
+    const cpl_parameter *param;
     /* --stropt */
     param = cpl_parameterlist_find_const(parlist,
-					 "iiinstrument.rrrecipe.string_option");
+					 "iiinstrument.rtest.string_option");
     const char *str_option = cpl_parameter_get_string(param);
     cpl_ensure_code(str_option != NULL, CPL_ERROR_NULL_INPUT);
 
     /* --boolopt */
     param = cpl_parameterlist_find_const(parlist,
-					 "iiinstrument.rrrecipe.bool_option");
+					 "iiinstrument.rtest.bool_option");
     int bool_option = cpl_parameter_get_bool(param);
 
     /* --floatopt */
     param = cpl_parameterlist_find_const(parlist,
-					 "iiinstrument.rrrecipe.float_option");
+					 "iiinstrument.rtest.float_option");
     double float_option = cpl_parameter_get_double(param);
 
     /* --intopt */
     param = cpl_parameterlist_find_const(parlist,
-					 "iiinstrument.rrrecipe.int_option");
+					 "iiinstrument.rtest.int_option");
     int int_option = cpl_parameter_get_int(param);
 
     /* --enumopt */
     param = cpl_parameterlist_find_const(parlist,
-					 "iiinstrument.rrrecipe.enum_option");
+					 "iiinstrument.rtest.enum_option");
     const char *enum_option = cpl_parameter_get_string(param);
 
-    /* --floatopt */
+    /* --rangeopt */
     param = cpl_parameterlist_find_const(parlist,
-					 "iiinstrument.rrrecipe.range_option");
+					 "iiinstrument.rtest.range_option");
     double range_option = cpl_parameter_get_double(param);
 
     /* --crashing */
     param = cpl_parameterlist_find_const(parlist,
-					 "iiinstrument.rrrecipe.crashing");
+					 "iiinstrument.rtest.crashing");
     const char *crashing = cpl_parameter_get_string(param);
 
+    /* --sleep */
+    param = cpl_parameterlist_find_const(parlist,
+					 "iiinstrument.rtest.sleep");
+    double sleep_secs = cpl_parameter_get_double(param);
+
     if (!cpl_errorstate_is_equal(prestate)) {
 	return (int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
 					  "Could not retrieve the input "
@@ -379,55 +325,54 @@ static int rrrecipe(cpl_frameset            * frameset,
     cpl_ensure_code(iiinstrument_dfs_set_groups(frameset) == CPL_ERROR_NONE,
 		    cpl_error_get_code());
 
-    /* HOW TO ACCESS INPUT DATA */
-    /*  - A required file */
-    rawframe = cpl_frameset_find_const(frameset, RRRECIPE_RAW);
+    /*  - raw input file */
+    const cpl_frame *rawframe = cpl_frameset_find_const(frameset, RRRECIPE_RAW);
     if (rawframe == NULL) {
 	/* cpl_frameset_find_const() does not set an error code, when a frame
 	   is not found, so we will set one here. */
 	return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
-					  "SOF does not have any file tagged "
-					  "with %s", RRRECIPE_RAW);
-    }
-    /* - A recommended file */
-    flat = cpl_frameset_find(frameset, IIINSTRUMENT_CALIB_FLAT);
-    if (flat == NULL) {
-	cpl_msg_warning(cpl_func, "SOF does not have any file tagged with %s",
-			IIINSTRUMENT_CALIB_FLAT);
+					  "No file tagged with %s", RRRECIPE_RAW);
     }
 
-    /* HOW TO GET THE VALUE OF A FITS KEYWORD */
-    /*  - Load only DETector related keys */
-    plist = cpl_propertylist_load_regexp(cpl_frame_get_filename(rawframe),
-					 0, "ESO DET ", 0);
+    cpl_propertylist *plist
+	= cpl_propertylist_load_regexp(cpl_frame_get_filename(rawframe),
+				       0, "ESO DET ", 0);
     if (plist == NULL) {
 	/* In this case an error message is added to the error propagation */
+	cpl_msg_error(cpl_func, "Could not read plist from %s",
+		      cpl_frame_get_filename(rawframe));
 	return (int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
 					  "Could not read the FITS header");
     }
 
-    qc_param = iiinstrument_pfits_get_dit(plist);
+    double qc_param = iiinstrument_pfits_get_dit(plist);
+    cpl_errorstate_set(prestate);
+
     cpl_propertylist_delete(plist);
 
+    /* - calibration input file */
+    const cpl_frame *flat = cpl_frameset_find(frameset,IIINSTRUMENT_CALIB_FLAT);
+    if (flat == NULL) {
+	cpl_msg_warning(cpl_func, "No file tagged with %s",
+			IIINSTRUMENT_CALIB_FLAT);
+    }
+
     /* Check for a change in the CPL error state */
     /* - if it did change then propagate the error and return */
     cpl_ensure_code(cpl_errorstate_is_equal(prestate), cpl_error_get_code());
 
-    /* NOW PERFORMING THE DATA REDUCTION */
-    /* Let's just load an image for the example */
-    usleep(10000);
-    image = cpl_image_load(cpl_frame_get_filename(rawframe),
-			   CPL_TYPE_FLOAT, 0, 0);
-    if (image == NULL) {
-	return (int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
-				     "Could not load the image");
-    }
+    /* Load raw image */
+    cpl_image *image = cpl_image_load(cpl_frame_get_filename(rawframe),
+				      CPL_TYPE_FLOAT, 0, 0);
+
+    /* Do some fake processing */
+    usleep((unsigned int)(1e6*sleep_secs));
 
     /* Add QC parameters  */
-    qclist = cpl_propertylist_new();
+    cpl_propertylist *qclist = cpl_propertylist_new();
 
     cpl_propertylist_append_double(qclist, "ESO QC QCPARAM", qc_param);
-    cpl_propertylist_append_string(qclist, "ESO PRO CATG", RRRECIPE_XXX_PROCATG);
+    cpl_propertylist_append_string(qclist, "ESO PRO CATG","THE_PRO_CATG_VALUE");
     if (str_option != NULL) {
 	cpl_propertylist_append_string(qclist, "ESO QC STROPT", str_option);
     } else {
@@ -446,12 +391,11 @@ static int rrrecipe(cpl_frameset            * frameset,
 
     prestate = cpl_errorstate_get();
 
-    /* HOW TO SAVE A DFS-COMPLIANT PRODUCT TO DISK  */
     if (cpl_dfs_save_image(frameset, NULL, parlist, frameset, NULL, image,
 			   CPL_BPP_IEEE_FLOAT,
-			   "rrrecipe", qclist, NULL,
+			   "rtest", qclist, NULL,
 			   PACKAGE "/" PACKAGE_VERSION,
-			   "rrrecipe.fits")) {
+			   "rtest.fits")) {
 	/* Propagate the error */
 	(void)cpl_error_set_where(cpl_func);
     }

-- 
Control pipeline recipes from the European Southern Observatory



More information about the debian-science-commits mailing list