IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19399


Ignore:
Timestamp:
Sep 5, 2008, 12:41:58 PM (18 years ago)
Author:
bills
Message:

Get configuration dump file name from command line option. If no file
is provided, no dump is created

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppImageArguments.c

    r18895 r19399  
    132132    }
    133133
     134    if ((argnum = psArgumentGet(argc, argv, "-dumpconfig"))) {
     135        psArgumentRemove(argnum, &argc, argv);
     136        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "DUMP_CONFIG", PS_META_REPLACE,
     137                         "Filename for configuration dump", argv[argnum]);
     138        psArgumentRemove(argnum, &argc, argv);
     139    }
     140
    134141    if (argc != 2) usage ();
    135142
  • trunk/ppImage/src/ppImageLoop.c

    r19044 r19399  
    2828    }
    2929
    30     {
     30    psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG");
     31    if (dump_file) {
    3132        pmConfigCamerasCull(config, NULL);
    3233        pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO");
    3334
    34         const char *outroot = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // Output root name
    35         psAssert(outroot, "Should be there, we put it there!");
    36         pmConfigDump(config, input->fpa, outroot);
     35        pmConfigDump(config, input->fpa, dump_file);
    3736    }
    3837
  • trunk/ppStack/src/ppStackArguments.c

    r19283 r19399  
    145145
    146146    pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSTACK.SOURCES", "-sources", NULL);
     147
     148    if ((argNum = psArgumentGet(argc, argv, "-dumpconfig"))) {
     149        psArgumentRemove(argNum, &argc, argv);
     150        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "DUMP_CONFIG", PS_META_REPLACE,
     151                         "Filename for configuration dump", argv[argNum]);
     152        psArgumentRemove(argNum, &argc, argv);
     153    }
     154
     155
    147156
    148157    psMetadata *arguments = config->arguments; // Command-line arguments
     
    288297
    289298    // Dump configuration, now that's it's settled
    290     {
     299    bool status;
     300    psString dump_file =  psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG");
     301    if (dump_file) {
    291302        pmConfigCamerasCull(config, NULL);
    292303        pmConfigRecipesCull(config, "PPSTACK,PPSUB,PPSTATS,PSPHOT,MASKS");
    293304
    294         const char *outroot = psMetadataLookupStr(NULL, arguments, "OUTPUT"); // Output root name
    295         psAssert(outroot, "Should be there, we put it there!");
    296 
    297305        pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSTACK.INPUT"); // Input file
    298         pmConfigDump(config, input->fpa, outroot);
     306        pmConfigDump(config, input->fpa, dump_file);
    299307    }
    300308
  • trunk/ppSub/src/ppSubArguments.c

    r19165 r19399  
    219219    psMetadataAddBool(arguments, PS_LIST_TAIL, "-photometry", 0, "Perform photometry?", false);
    220220    psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Number of threads", 0);
     221    psMetadataAddStr(arguments, PS_LIST_TAIL, "-dumpconfig", 0, "file to dump configuration to", NULL);
    221222
    222223    if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 4) {
     
    345346
    346347    // Dump configuration, now that's it's settled
    347     {
     348    psBool status;
     349    psString dump_file =  psMetadataLookupStr(&status, config->arguments, "-dumpconfig");
     350    if (dump_file) {
    348351        pmConfigCamerasCull(config, NULL);
    349352        pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,MASKS");
    350353
    351         const char *outroot = psMetadataLookupStr(NULL, arguments, "OUTPUT"); // Output root name
    352         psAssert(outroot, "Should be there, we put it there!");
    353 
    354354        pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file
    355         pmConfigDump(config, input->fpa, outroot);
     355        pmConfigDump(config, input->fpa, dump_file);
    356356    }
    357357
  • trunk/psModules/src/config/pmConfigDump.c

    r19047 r19399  
    106106
    107107
    108 bool pmConfigDump(const pmConfig *config, const pmFPA *source, const char *outroot)
     108bool pmConfigDump(const pmConfig *config, const pmFPA *source, const char *filename)
    109109{
    110110    PS_ASSERT_PTR_NON_NULL(config, false);
    111     PS_ASSERT_STRING_NON_EMPTY(outroot, false);
    112 
    113     pmFPAview *view = source ? pmFPAviewTop(source) : pmFPAviewAlloc(0);// View to top level
    114     if (!view) {
    115         psError(PS_ERR_UNKNOWN, false, "Unable to determine top view for FPA.");
    116         return false;
    117     }
    118 
    119     pmFPALevel level = pmFPAviewLevel(view); // Level for view
    120     const char *levelString;    // String for level
    121     switch (level) {
    122       case PM_FPA_LEVEL_FPA:
    123         levelString = "FPA";
    124         break;
    125       case PM_FPA_LEVEL_CHIP:
    126         levelString = "CHIP";
    127         break;
    128       case PM_FPA_LEVEL_CELL:
    129         levelString = "CELL";
    130         break;
    131       default:
    132         psError(PS_ERR_UNKNOWN, false, "Bad FPA level: %x", level);
    133         psFree(view);
    134         return false;
    135     }
    136 
    137     psMetadata *dumpRules = psMetadataLookupMetadata(NULL, config->system, "CONFIG.DUMP"); // Name rules
    138     if (!dumpRules) {
    139         psError(PS_ERR_UNKNOWN, false, "Unable to find CONFIG.DUMP in system configuration");
    140         psFree(view);
    141         return false;
    142     }
    143 
    144     const char *rule = psMetadataLookupStr(NULL, dumpRules, levelString); // Rule for output file name
    145     if (!rule) {
    146         psError(PS_ERR_UNKNOWN, false, "Unable to find %s in CONFIG.DUMP in system configuration",
    147                 levelString);
    148         psFree(view);
    149         return false;
    150     }
    151 
    152     psString ruleCopy = psStringCopy(rule); // Copy of rule, so we can have our way with it
    153 
    154     psStringSubstitute(&ruleCopy, outroot, "{OUTPUT}");
    155 
    156     if (strstr(ruleCopy, "{PROGRAM}")) {
    157         // basename() is allowed to muck with the values, so need to copy
    158         psString program = psStringCopy(config->program); // Copy of program name
    159         const char *progName = basename(program); // Basename of program
    160         psStringSubstitute(&ruleCopy, progName, "{PROGRAM}");
    161         psFree(program);
    162     }
    163 
    164     if (strstr(ruleCopy, "{TIMESTAMP}")) {
    165         psTime *time = psTimeGetNow(PS_TIME_UTC); // Current time
    166         psString timeString = psTimeToISO(time); // ISO-formatted time
    167         psFree(time);
    168         psStringSubstitute(&ruleCopy, timeString, "{TIMESTAMP}");
    169         psFree(timeString);
    170     }
    171 
    172     psString filename = pmFPANameFromRule(ruleCopy, source, view); // Filename for dump
    173     psFree(ruleCopy);
    174     psFree(view);
    175     if (!filename) {
    176         psError(PS_ERR_UNKNOWN, false, "Unable to determine dump filename");
    177         return false;
    178     }
     111    PS_ASSERT_STRING_NON_EMPTY(filename, false);
    179112
    180113    psString resolved = pmConfigConvertFilename(filename, config, true, false); // Resolved filename
     
    182115    if (!psMetadataConfigWrite(config->user, resolved)) {
    183116        psError(PS_ERR_IO, false, "Unable to dump configuration to %s", filename);
    184         psFree(filename);
    185117        psFree(resolved);
    186118        return false;
    187119    }
    188120
    189     psFree(filename);
    190121    psFree(resolved);
    191122
  • trunk/psModules/src/config/pmConfigDump.h

    r19042 r19399  
    44 *  @author Paul Price, IfA
    55 *
    6  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2008-08-13 02:32:35 $
     6 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2008-09-05 22:41:58 $
    88 *  Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    3030/// Dump the configuration to a file
    3131///
    32 /// The output file is designated by the CONFIG.DUMP metadata in the system configuration, keyed by the FPA
    33 /// level of the supplied source.  In addition to the standard concept interpolation, additional
    34 /// interpolations are defined: "{PROGRAM}" is interpolated to the program name, "{TIMESTAMP}" is interpolated
    35 /// to the current time (ISO format).
    3632bool pmConfigDump(const pmConfig *config, ///< Configuration to dump
    37                   const pmFPA *source,  ///< Source FPA, defines the level for the file rule
    38                   const char *outroot   ///< Output root name
     33                  const pmFPA *source,    ///< Source FPA, defines the level for the file rule
     34                  const char *filename    ///< Output file name
    3935    );
    4036
  • trunk/pswarp/src/pswarpArguments.c

    r19043 r19399  
    5959        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "PSF", 0, "Do PSF determination?", true);
    6060    }
     61    if ((N = psArgumentGet(argc, argv, "-dumpconfig"))) {
     62        psArgumentRemove(N, &argc, argv);
     63        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "DUMP_CONFIG", PS_META_REPLACE,
     64                         "Filename for configuration dump", argv[N]);
     65        psArgumentRemove(N, &argc, argv);
     66    }
     67
    6168
    6269    if (!pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list")) {
     
    166173
    167174    // Dump configuration, now that's it's settled
    168     {
     175    psString dump_file =  psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG");
     176    if (dump_file) {
    169177        const char *skyCamera = psMetadataLookupStr(NULL, config->arguments,
    170178                                                    "SKYCELL.CAMERA");  // Name of camera for skycell
     
    172180        pmConfigRecipesCull(config, "PSWARP,PPSTATS,PSPHOT,MASKS");
    173181
    174         const char *outroot = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // Output root name
    175         psAssert(outroot, "Should be there, we put it there!");
    176 
    177182        pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PSWARP.INPUT"); // Input file
    178         pmConfigDump(config, input->fpa, outroot);
     183        pmConfigDump(config, input->fpa, dump_file);
    179184    }
    180185
Note: See TracChangeset for help on using the changeset viewer.