IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2014, 4:14:54 PM (12 years ago)
Author:
eugene
Message:

merge from trunk; add -photcode-rule option to pmConfig

Location:
branches/eam_branches/ipp-20140610/psModules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140610/psModules

  • branches/eam_branches/ipp-20140610/psModules/src/config/pmConfig.c

    r36375 r36916  
    964964            psMetadataAddMetadata(filerules, PS_LIST_TAIL, rulename, PS_META_REPLACE,
    965965                                  "Original replaced by -R option", newRule);
     966        }
     967        psFree(camerasIter);
     968    }
     969
     970    // Look for command-line options for files to replace
     971    while ((argNum = psArgumentGet(*argc, argv, "-photcode-rule")) > 0) {
     972        psArgumentRemove(argNum, argc, argv);
     973        if (argNum >= *argc) {
     974            psError(PM_ERR_CONFIG, true,
     975                    "-photcode-rule provided without new rule.");
     976            psFree(config);
     977            return NULL;
     978        }
     979
     980        psString newrule = psStringCopy(argv[argNum]); // The filerule, to be modified
     981        psArgumentRemove(argNum, argc, argv);
     982
     983        psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // List of cameras
     984        if (!cameras) {
     985            psError(PM_ERR_CONFIG, false, "Unable to find CAMERAS in the site configuration.\n");
     986            return false;
     987        }
     988
     989        psMetadataIterator *camerasIter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, NULL); // Iterator
     990        psMetadataItem *cameraItem;     // Item from iteration
     991        while ((cameraItem = psMetadataGetAndIncrement(camerasIter))) {
     992            // Silently ignore problems --- they will be caught later, because if the user wants the nominated
     993            // file and it's not available for that camera, then they will know.
     994
     995            if (cameraItem->type != PS_DATA_METADATA) {
     996                psTrace("psModules.config", 2,
     997                        "Entry %s in CAMERAS is not of type METADATA --- ignored.", cameraItem->name);
     998                continue;
     999            }
     1000            psMetadata *camera = cameraItem->data.md; // Camera configuration
     1001
     1002            psMetadataAddStr (camera, PS_LIST_TAIL, "PHOTCODE.RULE", PS_META_REPLACE, "original replaced by -photcode-rule option", newrule);
    9661003        }
    9671004        psFree(camerasIter);
Note: See TracChangeset for help on using the changeset viewer.