IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 11, 2007, 1:28:15 PM (19 years ago)
Author:
Paul Price
Message:

"-F OLD NEW" on the command line does file rule redirection. The new
file rule replaces the old file rule, for all cameras.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r13346 r13355  
    44 *  @author EAM (IfA)
    55 *
    6  *  @version $Revision: 1.93 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-05-11 03:40:18 $
     6 *  @version $Revision: 1.94 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-05-11 23:28:15 $
    88 *
    99 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    593593    pmConfigLoadRecipeOptions(argc, argv, config, "-Db");
    594594
     595    // Look for command-line options for files to replace
     596    argNum = psArgumentGet(*argc, argv, "-F");
     597    if (argNum > 0) {
     598        psArgumentRemove(argNum, argc, argv);
     599        if (argNum + 1 >= *argc) {
     600            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     601                    "Filerule switch (-F) provided without old and new filerule.");
     602            psFree(config);
     603            return NULL;
     604        }
     605
     606        const char *old = argv[argNum]; // The old file, to be replaced
     607        psArgumentRemove(argNum, argc, argv);
     608        const char *new = argv[argNum]; // The new file, the replacement
     609        psArgumentRemove(argNum, argc, argv);
     610
     611        psMetadata *cameras = psMetadataLookupMetadata(NULL, config->site, "CAMERAS"); // List of cameras
     612        if (!cameras) {
     613            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find CAMERAS in the site configuration.\n");
     614            return false;
     615        }
     616
     617        psMetadataIterator *camerasIter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, NULL); // Iterator
     618        psMetadataItem *cameraItem;     // Item from iteration
     619        while ((cameraItem = psMetadataGetAndIncrement(camerasIter))) {
     620            if (cameraItem->type != PS_DATA_METADATA) {
     621                psWarning("Entry %s in CAMERAS is not of type METADATA --- ignored.", cameraItem->name);
     622                continue;
     623            }
     624            psMetadata *camera = cameraItem->data.md; // Camera configuration
     625            psMetadata *filerules = psMetadataLookupMetadata(NULL, camera, "FILERULES"); // File rules
     626            if (!filerules) {
     627                psWarning("Can't find FILERULES of type METADATA in camera %s --- ignored.",
     628                          cameraItem->name);
     629                continue;
     630            }
     631            psMetadata *newRule = psMetadataLookupMetadata(NULL, filerules, new); // New rule (replacement)
     632            if (!newRule) {
     633                psWarning("Can't find file rule %s in camera %s --- ignored.", new, cameraItem->name);
     634                continue;
     635            }
     636            psMetadataAddMetadata(filerules, PS_LIST_TAIL, old, PS_META_REPLACE,
     637                                  "Original replaced by -F option", newRule);
     638        }
     639        psFree(camerasIter);
     640    }
     641
    595642    // check for values that override DB* keywords
    596643    argNum = psArgumentGet(*argc, argv, "-dbserver");
Note: See TracChangeset for help on using the changeset viewer.