IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16611


Ignore:
Timestamp:
Feb 22, 2008, 10:21:52 AM (18 years ago)
Author:
eugene
Message:

using new user/site/system construction for config files

Location:
trunk
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-Config/lib/PS/IPP/Config.pm

    r16325 r16611  
    11# Copyright (c) 2006  Paul Price, Joshua Hoblitt
    22#
    3 # $Id: Config.pm,v 1.75 2008-02-06 02:05:44 price Exp $
     3# $Id: Config.pm,v 1.76 2008-02-22 20:20:37 eugene Exp $
    44
    55package PS::IPP::Config;
     
    6262    my $name;                   # Name of ipprc file
    6363    GetOptions( 'site=s' => \$name );
    64     $name = $ENV{PS_SITE} if not defined $name;
     64    $name = $ENV{IPPRC} if not defined $name;
    6565    if (not defined $name and defined $ENV{HOME}) {
    6666        $name = $ENV{HOME} . '/.ipprc';
     
    9090        filerules => undef,     # File rules from the camera configuration
    9191        rejection => undef,     # Rejection data
    92         _ipprc => $mdc          # The parsed configuration
     92        _userConfig => $mdc,    # The top-level user configuration
     93        _siteConfig => undef,   # The site configuration (from _userConfig)
     94        _systemConfig => undef  # The system configuration (from _userConfig)
    9395        };
    9496    bless $self, $class;
     97
     98    $self->load_site();
     99    $self->load_system();
    95100
    96101    $self->define_camera($camera) if defined $camera;
     
    140145}
    141146
     147# Load the site config file
     148sub load_site
     149{
     150    my $self = shift;           # Configuration object
     151
     152    my $i = 0;
     153
     154    unless (defined $self) {
     155        carp "Programming error";
     156        exit($PS_EXIT_PROG_ERROR);
     157    }
     158
     159    my $filename = metadataLookupStr($self->{_userConfig}, 'SITE'); # Site config file
     160    unless (defined $filename) {
     161        carp "Unable to find site configuration file\n";
     162        exit($PS_EXIT_CONFIG_ERROR);
     163    }
     164
     165    my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH
     166
     167    # Read the file
     168    my $file;                   # File handle
     169    unless (open $file, $realfile) {
     170        carp "Unable to open site configuration file $realfile: $!";
     171        exit($PS_EXIT_CONFIG_ERROR);
     172    }
     173
     174    my @contents = <$file>;
     175    close $file;
     176    $self->{_siteConfig} = $parser->parse( join '', @contents); # The parsed metadata config
     177
     178    unless (defined $self->{_siteConfig}) {
     179        carp "Failure to parse the site configuration file $realfile";
     180        exit($PS_EXIT_CONFIG_ERROR);
     181    }
     182
     183    return $self;
     184}
     185
     186# Load the system config file
     187sub load_system
     188{
     189    my $self = shift;           # Configuration object
     190
     191    unless (defined $self) {
     192        carp "Programming error";
     193        exit($PS_EXIT_PROG_ERROR);
     194    }
     195
     196    my $filename = metadataLookupStr($self->{_userConfig}, 'SYSTEM'); # System config file
     197    unless (defined $filename) {
     198        carp "Unable to find system configuration file\n";
     199        exit($PS_EXIT_CONFIG_ERROR);
     200    }
     201
     202    my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH
     203
     204    # Read the file
     205    my $file;                   # File handle
     206    unless (open $file, $realfile) {
     207        carp "Unable to open system configuration file $realfile: $!";
     208        exit($PS_EXIT_CONFIG_ERROR);
     209    }
     210    my @contents = <$file>;
     211    close $file;
     212    $self->{_systemConfig} = $parser->parse( join '', @contents); # The parsed metadata config
     213
     214    unless (defined $self->{_systemConfig}) {
     215        carp "Failure to define system configuration";
     216        exit($PS_EXIT_CONFIG_ERROR);
     217    }
     218
     219    # XXX why isn't just $self being returned here? -JH
     220    return $self;
     221}
     222
    142223# Define a camera to use
    143224sub define_camera
     
    151232    }
    152233
    153     my $camera_list = metadataLookupMD($self->{_ipprc}, 'CAMERAS'); # List of cameras
     234    my $camera_list = metadataLookupMD($self->{_systemConfig}, 'CAMERAS'); # List of cameras
    154235    my $filename = metadataLookupStr($camera_list, $name); # Filename of camera configuration
    155236    unless (defined $filename) {
     
    233314    }
    234315
    235     my $path_list = metadataLookupMD($self->{_ipprc}, 'DATAPATH'); # List of paths
     316    my $path_list = metadataLookupMD($self->{_siteConfig}, 'DATAPATH'); # List of paths
    236317    my $pathname = metadataLookupStr($path_list, $name); # Path of interest
    237318    unless (defined $pathname) {
     
    258339    return 1 if defined $self->{nebulous}; # Already started
    259340
    260     my $server = metadataLookupStr( $self->{_ipprc}, 'NEB_SERVER' ); # Nebulous server
     341    my $server = metadataLookupStr( $self->{_siteConfig}, 'NEB_SERVER' ); # Nebulous server
    261342    unless (defined $server) {
    262343        carp "Unable to find NEB_SERVER in camera configuration file.";
     
    561642    my @dirs = File::Spec->splitdir( $name );
    562643   
    563     my $path_list = metadataLookupMD($self->{_ipprc}, 'DATAPATH'); # List of paths
     644    my $path_list = metadataLookupMD($self->{_siteConfig}, 'DATAPATH'); # List of paths
    564645    my $best_path;
    565646    my $best_name;
     
    790871    my $tess_id = shift;        # Tessellation identifier
    791872
    792     unless (defined $self and defined $self->{_ipprc} and defined $tess_id) {
    793         carp "Programming error";
    794         exit($PS_EXIT_PROG_ERROR);
    795     }
    796 
    797     my $tessellations = metadataLookupMD($self->{_ipprc}, 'TESSELLATIONS'); # Tessellations
     873    unless (defined $self and defined $self->{_siteConfig} and defined $tess_id) {
     874        carp "Programming error";
     875        exit($PS_EXIT_PROG_ERROR);
     876    }
     877
     878    my $tessellations = metadataLookupMD($self->{_siteConfig}, 'TESSELLATIONS'); # Tessellations
    798879    unless (defined $tessellations) {
    799880        carp "Can't find TESSELLATIONS in site configuration.\n";
     
    817898}
    818899
     900
     901# Return catdir for the dvo db, from DVO.CATDIRS within the site configuration
     902sub dvo_catdir
     903{
     904    my $self = shift;   # Configuration object
     905    my $dvodb = shift;  # DVO db identifier
     906
     907    unless (defined $self and defined $self->{_siteConfig} and defined $dvodb) {
     908        carp "Programming error";
     909        exit($PS_EXIT_PROG_ERROR);
     910    }
     911
     912    my $catdirs = metadataLookupMD($self->{_siteConfig}, 'DVO.CATDIRS'); # Tessellations
     913    unless (defined $catdirs) {
     914        carp "Can't find DVO.CATDIRS in site configuration.\n";
     915        exit($PS_EXIT_CONFIG_ERROR);
     916    }
     917
     918    my $catdir = metadataLookupStr($catdirs, $dvodb);
     919    unless (defined $catdir) {
     920        carp "Can't find dvodb identifier $dvodb in DVO.CATDIR in site configuration.\n";
     921        exit($PS_EXIT_CONFIG_ERROR);
     922    }
     923
     924    ### Because DVO doesn't use psModules, it doesn't understand Nebulous --- check
     925    my $scheme = file_scheme($catdir); # The scheme, e.g., file, path, neb
     926    if (defined $scheme and lc($scheme) eq 'neb') {
     927        carp "DVO catdir $dvodb refers to a Nebulous path: $catdir\n";
     928        exit($PS_EXIT_CONFIG_ERROR);
     929    }
     930
     931    return $catdir
     932}
     933
     934# Return catdir for the psastro reference, from PSASTRO.CATDIRS within the site configuration
     935sub psastro_catdir
     936{
     937    my $self = shift;   # Configuration object
     938    my $dvodb = shift;  # DVO db identifier
     939
     940    unless (defined $self and defined $self->{_siteConfig} and defined $dvodb) {
     941        carp "Programming error";
     942        exit($PS_EXIT_PROG_ERROR);
     943    }
     944
     945    my $catdirs = metadataLookupMD($self->{_siteConfig}, 'PSASTRO.CATDIRS'); # Tessellations
     946    unless (defined $catdirs) {
     947        carp "Can't find PSASTRO.CATDIRS in site configuration.\n";
     948        exit($PS_EXIT_CONFIG_ERROR);
     949    }
     950
     951    my $catdir = metadataLookupStr($catdirs, $dvodb);
     952    unless (defined $catdir) {
     953        carp "Can't find dvodb identifier $dvodb in PSASTRO.CATDIR in site configuration.\n";
     954        exit($PS_EXIT_CONFIG_ERROR);
     955    }
     956
     957    ### Because DVO doesn't use psModules, it doesn't understand Nebulous --- check
     958    my $scheme = file_scheme($catdir); # The scheme, e.g., file, path, neb
     959    if (defined $scheme and lc($scheme) eq 'neb') {
     960        carp "PSASTRO catdir $dvodb refers to a Nebulous path: $catdir\n";
     961        exit($PS_EXIT_CONFIG_ERROR);
     962    }
     963
     964    return $catdir
     965}
    819966
    820967# Return the DVO.CAMERADIR in the camera configuration
  • trunk/ippTools/src/pxadminConfig.c

    r16588 r16611  
    3535    fprintf (stderr, " [mode] : -create | -delete\n\n");
    3636
    37     psString dbServer = psMetadataLookupStr(&status, config->modules->site, "DBSERVER");
    38     psString dbUsername = psMetadataLookupStr(&status, config->modules->site, "DBUSER");
    39     psString dbName = psMetadataLookupStr(&status, config->modules->site, "DBNAME");
    40     psS32 dbPort = psMetadataLookupS32(&status, config->modules->site, "DBPORT");
     37    // XXX EAM : this should be done with psDB function calls
     38    psString dbServer = psMetadataLookupStr(&status, config->modules->complete, "DBSERVER");
     39    psString dbUsername = psMetadataLookupStr(&status, config->modules->complete, "DBUSER");
     40    psString dbName = psMetadataLookupStr(&status, config->modules->complete, "DBNAME");
     41    psS32 dbPort = psMetadataLookupS32(&status, config->modules->complete, "DBPORT");
    4142
    4243    fprintf (stderr, "connecting to %s as %s (port %d)\n", dbServer, dbUsername, dbPort);
  • trunk/ippTools/src/pxtables.c

    r16588 r16611  
    116116    PS_ASSERT_PTR_NON_NULL(config, false);
    117117
    118     psString dbName = psMetadataLookupStr(&status, config->modules->site, "DBNAME");
     118    // XXX use the values defined in config->dbh?
     119    psString dbName = psMetadataLookupStr(&status, config->modules->complete, "DBNAME");
    119120
    120121    fprintf (stdout, "*** delete the chip tables from database %s? ***\n", dbName);
     
    136137    {
    137138        bool status;
    138         psString dbPassword = psMetadataLookupStr(&status, config->modules->site, "DBPASSWORD");
     139        psString dbPassword = psMetadataLookupStr(&status, config->modules->complete, "DBPASSWORD");
    139140        if (strcmp (answer, dbPassword)) {
    140141            psError(PS_ERR_UNKNOWN, true, "tables NOT deleleted");
  • trunk/ippconfig

    • Property svn:ignore
      •  

        old new  
        1212missing
        1313ipprc.config
         14site.config
  • trunk/ippconfig/.cvsignore

    r11577 r16611  
    1212missing
    1313ipprc.config
     14site.config
  • trunk/ippconfig/Makefile.am

    r15296 r16611  
    1515
    1616install_files = \
     17        site.config \
     18        system.config \
    1719        GSCregions.tbl \
    1820        dvo.photcodes
  • trunk/ippconfig/ipprc.config.in

    r16482 r16611  
    1 ### Example .ipprc file
     1## Example .ipprc file : copy to your home directory and modify as desired
    22
    33# Default search path for configuration files (add $HOME if desired)
     4# Note: do not include $HOME in the distributed copy used by ippMonitor
    45# PATH            STR     @pkgdatadir@:$HOME/.ipp:.
    5 PATH            STR     @pkgdatadir@:.
    6 # note: do not include $HOME in the distributed copy used by ippMonitor
     6PATH              STR     @pkgdatadir@:.
    77
    8 # place your data directories here and refer to as path://PATH/remainder
    9 DATAPATH        METADATA
    10         ALALA   STR     /data/alala.0/
    11         ISP     STR     /data/ipp000.0/isp
    12         ISP_V2  STR     /data/ipp000.0/isp_v2
    13         ISP_V3  STR     /data/ipp000.0/isp_v3
    14         ISP_TEST STR    /data/ipp000.0/isp_test
    15         EAMTEST STR     /data/alala.0/eugene/swtests/simtest/raw
    16         EAMWORK STR     /data/alala.0/eugene/swtests/simtest/work
    17         CFH12K  STR     /data/ipp003.0/eugene/cfh12k
    18         DATA1   STR     /data/alala.0/
    19         SRESS1  STR     /data/ipp003.0/SM_W/sm030927/
    20         SRESSWORK STR   /data/ipp003.0/rodney/sresswork
    21         SIMTEST STR     /data/po05.0/rodney/sim/
    22         SIMWORK STR     /data/po05.0/rodney/simwork/
    23         MOPS    STR     /data/ipp002.0/MOPS/
    24         TALCS   STR     /data/ipp003.0/TALCS/
    25 END
     8# load the site-specific information from here
     9SITE              STR     site.config
    2610
    27 NEB_SERVER      STR     http://alala:80/nebulous        # Nebulous server
     11# load the system configuration information from here
     12SYSTEM            STR     system.config
    2813
    29 ### Database configuration
    30 DBSERVER        STR     ipp000                  # Database host name (for psDBInit)
    31 DBNAME          STR     ipp                     # Database name (for psDBInit)
    32 DBUSER          STR     XXX                     # Database user name (for psDBInit)
    33 DBPASSWORD      STR     XXX                     # Database password (for psDBInit)
    34 
    35 ### Setups for each camera system
    36 CAMERAS         METADATA
    37         MEGACAM                 STR     megacam/camera.config
    38         CFH12K                  STR     cfh12k/camera.config
    39         ISP-Apogee              STR     isp/camera.config
    40         CTIO_MOSAIC2            STR     ctio_mosaic2/camera.config      # CTIO MOSAIC2 camera, for ESSENCE
    41         SDSS                    STR     sdss/camera.config              # Sloan Digital Sky Survey
    42         GPC1                    STR     gpc1/camera.config
    43         ESOWFI                  STR     esowfi/camera.config            # ESO Wide-Field Imager
    44 #       UCAM                    STR     ucam/camera.config
    45 #       LRIS_BLUE               STR     lris_blue/camera.config
    46 #       TC3                     STR     tc3/camera.config               # Pan-STARRS Test Camera III
    47 #       LRIS_RED                STR     lris_red/camera.config
    48         SIMMOSAIC               STR     simmosaic/camera.config         # Simulated mosaic, for testing
    49         SIMTEST                 STR     simtest/camera.config
    50         SIMPLE                  STR     simple/camera.config
    51 END
    52 
    53 ### camera names as expected by DVO
    54 DVO.CAMERAS             METADATA
    55         MEGACAM                 STR     megacam
    56         CFH12K                  STR     cfh12k
    57         ISP-Apogee              STR     isp
    58         CTIO_MOSAIC2            STR     ctio_mosaic2
    59         SDSS                    STR     sdss
    60         GPC1                    STR     gpc1
    61         ESOWFI                  STR     esowfi
    62 #       UCAM                    STR     ucam
    63 #       TC3                     STR     tc3
    64 #       LRIS_BLUE               STR     lris_blue
    65 #       LRIS_RED                STR     lris_red
    66         SIMMOSAIC               STR     simmosaic
    67         SIMTEST                 STR     simtest
    68         SIMPLE                  STR     simple
    69 END
    70 
    71 ### psLib setup
    72 #TIME           STR     /home/mithrandir/price/pan-starrs/jhroot/i686-pc-linux-gnu/etc/pslib/psTime.config      # Time configuration file
     14# logging verbosity levels
    7315LOGLEVEL        S32     9                       # Logging level; 3=INFO
    7416LOGFORMAT       STR     THLNM                   # Log format
    7517LOGDEST         STR     STDERR                  # Log destination
    7618TRACEDEST       STR     STDERR                  # Trace destination
     19
     20# place default trace lines here
    7721TRACE           METADATA                        # Trace levels
    78         err             S32     10
    79 # place default trace lines here
    80 # example:
    81 # psLib.db S32  10
     22  err           S32     10
     23# psLib.db      S32     10
    8224END
    83 
    84 RECIPES         METADATA                # Site-level recipes
    85         MASKS           STR             recipes/masks.config    # Mask values
    86         REJECTIONS      STR             recipes/rejections.config # Rejection for detrend creation
    87         PPIMAGE         STR             recipes/ppImage.config  # Image reduction
    88         PPMERGE         STR             recipes/ppMerge.config  # Image combination
    89         PPSTATS         STR             recipes/ppStats.config  # Image statistics
    90         PSPHOT          STR             recipes/psphot.config   # Photometry
    91         PSASTRO         STR             recipes/psastro.config  # Astrometry
    92         PPSTACK         STR             recipes/ppStack.config  # Combination
    93         PSWARP          STR             recipes/pswarp.config   # Warping
    94         PPSIM           STR             recipes/ppSim.config    # Simulations
    95         PPSUB           STR             recipes/ppSub.config    # Subtraction
    96 END
    97 
    98 # Header keywords for skycell concepts; required because DVO doesn't read HIERARCH
    99 SKYCELLS        METADATA
    100         FPA.TIME        STR     MJD-OBS
    101         CELL.TIME       STR     MJD-OBS
    102         FPA.EXPOSURE    STR     EXPTIME
    103         CELL.EXPOSURE   STR     EXPTIME
    104         FPA.AIRMASS     STR     AIRMASS
    105 END
    106 
    107 # List of tessellations, and their DVO CATDIR
    108 TESSELLATIONS   METADATA
    109         MOPS            STR     path://MOPS/skycells/
    110 END
  • trunk/ppConfigDump/src/ppConfigDump.c

    r14189 r16611  
    112112    }
    113113
     114    const char *userName = psMetadataLookupStr(NULL, arguments, "-dump-user"); // User filename
     115    dump(userName, "user configuration", config->user);
     116
    114117    const char *siteName = psMetadataLookupStr(NULL, arguments, "-dump-site"); // Site filename
    115118    dump(siteName, "site configuration", config->site);
     119
     120    const char *systemName = psMetadataLookupStr(NULL, arguments, "-dump-system"); // System filename
     121    dump(systemName, "system configuration", config->system);
     122
     123    const char *completeName = psMetadataLookupStr(NULL, arguments, "-dump-complete"); // Complete filename
     124    dump(completeName, "complete configuration", config->complete);
    116125
    117126    const char *camName = psMetadataLookupStr(NULL, arguments, "-dump-camera"); // Camera filename
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r16481 r16611  
    155155    } else {
    156156        bool mdok;                      // Status of MD lookup
    157         psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->site, "CAMERAS"); // Known cameras
     157        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->complete, "CAMERAS"); // Known cameras
    158158        if (!mdok || !cameras) {
    159             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n");
     159            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
    160160            return NULL;
    161161        }
     
    163163        if (!mdok || !camera) {
    164164            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find automatically generated "
    165                     "camera configuration %s in site configuration.\n", cameraName);
     165                    "camera configuration %s in system configuration.\n", cameraName);
    166166            return NULL;
    167167        }
  • trunk/psModules/src/config/pmConfig.c

    r16415 r16611  
    3434#endif // ifdef HAVE_NEBCLIENT
    3535
    36 #define PS_SITE "PS_SITE"         // Name of the environment variable containing the site config file
    37 #define PS_DEFAULT_SITE ".ipprc"  // Default site config file
     36#define IPPRC_ENV "IPPRC"        // Name of the environment variable containing the top-level config file
     37#define IPPRC_FILE ".ipprc"      // Default top-level config file
    3838
    3939#define DEFAULT_LOG STDERR_FILENO       // Default file descriptor for log messages
     
    5252static void configFree(pmConfig *config)
    5353{
     54    psFree(config->user);
    5455    psFree(config->site);
     56    psFree(config->system);
     57    psFree(config->complete);
    5558    psFree(config->files);
    5659    psFree(config->camera);
     
    8083
    8184    // Initialise
     85    config->user = NULL;
    8286    config->site = NULL;
     87    config->system = NULL;
     88    config->complete = NULL;
    8389    config->camera = NULL;
    8490    config->cameraName = NULL;
     
    145151    PS_ASSERT_STRING_NON_EMPTY(path,);
    146152
    147     pmConfigDone();
     153    assert (configPath == NULL);
     154    // XXX why was this being called?  pmConfigSet should only be called once...
     155    // pmConfigDone();
    148156
    149157    psList *list = psStringSplit(path, ":", false);
     
    159167void pmConfigDone(void)
    160168{
    161     psFree(configPath);
     169    if (configPath) {
     170        psFree(configPath);
     171    }
    162172    configPath = NULL;
    163173
     
    380390    config->defaultRecipe = defaultRecipe;
    381391
    382     //
    383     // The following section of code attempts to determine which file is
    384     // the configuration file.  At the end of this code block, the siteName
     392    // The following section of code attempts to determine which file to use as the
     393    // top-level the configuration file.  At the end of this code block, the configFile
    385394    // variable will contain the name of the configuration file.
    386     //
    387     char *siteName = NULL;
     395
     396    char *configFile = NULL;
    388397    //
    389398    // First, try command line
    390399    //
    391     psS32 argNum = psArgumentGet(*argc, argv, "-site");
     400    psS32 argNum = psArgumentGet(*argc, argv, "-ipprc");
    392401    if (argNum != 0) {
    393         //
    394         // We remove the "-site" argument from argv.  Then
    395         // we look for the next argument, which should be the filename, and
    396         // remove it as well.
    397         //
     402        // remove the "-ipprc" argument from argv, check and remove filename
    398403        psArgumentRemove(argNum, argc, argv);
    399404        if (argNum >= *argc) {
    400             psWarning("-site command-line switch provided without the required filename --- ignored.\n");
     405            psWarning("-ipprc command-line switch provided without the required filename --- ignored.\n");
    401406        } else {
    402             siteName = psStringCopy(argv[argNum]);
     407            configFile = psStringCopy(argv[argNum]);
    403408            psArgumentRemove(argNum, argc, argv);
    404409        }
     
    407412    // Next, try environment variable
    408413    //
    409     if (!siteName) {
    410         siteName = getenv(PS_SITE);
    411         if (siteName) {
    412             siteName = psStringCopy (siteName);
     414    if (!configFile) {
     415        configFile = getenv(IPPRC_ENV);
     416        if (configFile) {
     417            configFile = psStringCopy (configFile);
    413418        }
    414419    }
     
    417422    // Last chance is ~/.ipprc
    418423    //
    419     if (!siteName) {
     424    if (!configFile) {
    420425        char *home = getenv("HOME");
    421         siteName = psStringCopy(home);
    422         psStringAppend(&siteName, "/%s", PS_DEFAULT_SITE);
    423     }
    424 
     426        configFile = psStringCopy(home);
     427        psStringAppend(&configFile, "/%s", IPPRC_FILE);
     428    }
    425429
    426430    // We have the configuration filename; now we read and parse the config
    427     // file and store in psMetadata struct site.
    428     //
    429 
    430     if (!pmConfigFileRead(&config->site, siteName, "site")) {
     431    // file and store in psMetadata struct user.
     432    // XXX move this section to pmConfigReadUser.c ?
     433
     434    if (!pmConfigFileRead(&config->user, configFile, "user")) {
    431435        psFree(config);
    432436        return NULL;
    433437    }
    434438
    435     // Set options based on the site configuration.
     439    // XXX why was this being called here?  Is someone calling pmConfigRead multiple times?
     440    // pmConfigDone();
     441    assert (configPath == NULL); 
     442
     443    // define the config-file search path (configPath). 
     444    psString path = psMetadataLookupStr(NULL, config->user, "PATH");
     445    pmConfigSet (path);
     446
     447    // read the SITE file
     448    psString siteFile = psMetadataLookupStr(NULL, config->user, "SITE");
     449    if (!pmConfigFileRead(&config->site, siteFile, "site")) {
     450        psFree(config);
     451        return NULL;
     452    }
     453
     454    // load the SYSTEM file
     455    psString systemFile = psMetadataLookupStr(NULL, config->user, "SYSTEM");
     456    if (!pmConfigFileRead(&config->system, systemFile, "system")) {
     457        psFree(config);
     458        return NULL;
     459    }
     460
     461    // interpolate USER, SITE and SYSTEM into the config->complete metadata
     462    config->complete = psMetadataCopy (NULL,             config->user);
     463    config->complete = psMetadataCopy (config->complete, config->site);
     464    config->complete = psMetadataCopy (config->complete, config->system);
     465
     466    // Set LOG and TRACE options based on the user configuration.  These must be set AFTER
     467    // the SITE and SYSTEM config files are read so path:// entries here can be resolved.
    436468    {
    437469        bool mdok = true;   // Status of MD lookup result
    438470
    439         // Initialise the psLib time handling
    440         psString timeName = psMetadataLookupStr(&mdok, config->site, "TIME");
    441         if (mdok && timeName)
    442         {
    443             psTrace("psModules.config", 7, "Initialising psTime with file %s\n", timeName);
    444             psTimeInit(timeName);
    445         }
    446 
    447 
    448471        // Set logging level
    449         int logLevel = psMetadataLookupS32(&mdok, config->site, "LOGLEVEL");
     472        int logLevel = psMetadataLookupS32(&mdok, config->user, "LOGLEVEL");
    450473        if (mdok && logLevel >= 0)
    451474        {
     
    456479
    457480        // Set logging format
    458         psString logFormat = psMetadataLookupStr(&mdok, config->site, "LOGFORMAT");
     481        psString logFormat = psMetadataLookupStr(&mdok, config->user, "LOGFORMAT");
    459482        if (mdok && logFormat)
    460483        {
     
    463486        }
    464487
    465         // Set logging destination first from command line, second from site configuration
     488        // Set logging destination first from command line, second from user configuration
    466489        psString logDest = NULL;        // Logging destination
    467490        argNum = psArgumentGet(*argc, argv, "-log");
     
    477500        }
    478501        if (!logDest) {
    479             logDest = psMemIncrRefCounter(psMetadataLookupStr(&mdok, config->site, "LOGDEST"));
     502            logDest = psMemIncrRefCounter(psMetadataLookupStr(&mdok, config->user, "LOGDEST"));
    480503        }
    481504        if (logDest) {
     
    497520
    498521        // Set trace levels
    499         psMetadata *trace = psMetadataLookupMetadata(&mdok, config->site, "TRACE");
     522        psMetadata *trace = psMetadataLookupMetadata(&mdok, config->user, "TRACE");
    500523        if (mdok && trace) {
    501524            psMetadataIterator *traceIter = psMetadataIteratorAlloc(trace, PS_LIST_HEAD, NULL); // Iterator
     
    515538
    516539        // Set trace formats
    517         psString traceFormat = psMetadataLookupStr(&mdok, config->site, "TRACEFORMAT");
     540        psString traceFormat = psMetadataLookupStr(&mdok, config->user, "TRACEFORMAT");
    518541        if (mdok && traceFormat) {
    519542            psTrace("psModules.config", 7, "Setting trace format to %s\n", traceFormat);
     
    535558        }
    536559        if (!traceDest) {
    537             traceDest = psMemIncrRefCounter(psMetadataLookupStr(&mdok, config->site, "TRACEDEST"));
     560            traceDest = psMemIncrRefCounter(psMetadataLookupStr(&mdok, config->user, "TRACEDEST"));
    538561        }
    539562        if (traceDest) {
     
    563586    }
    564587
    565     // define the config-file search path (configPath).  Ensure that
    566     // it contains the directory where we found the config file in
    567     // the first place
    568     if (configPath) {
    569         pmConfigDone();
    570     }
    571 
    572     psString siteNameDir = psStringCopy(dirname(siteName));
    573     psFree(siteName);
    574 
    575     psString path = psMetadataLookupStr(NULL, config->site, "PATH");
    576     psString newPath = NULL;            // New path
    577     // The following gymnastics with 'newPath' are required to avoid changing the pointer out from under the
    578     // psMetadataItem on which 'path' sits (leading to memory corruption because it no longer points to valid
    579     // memory).
    580     if (path) {
    581         psStringAppend(&newPath, "%s:%s", path, siteNameDir);
    582     } else {
    583         newPath = psMemIncrRefCounter(siteNameDir);
    584     }
    585     psFree(siteNameDir);
    586     pmConfigSet(newPath);
    587     psFree(newPath);
     588    // XXX read TIME from SITE (or system?)
     589    {
     590        bool mdok = true;
     591
     592        // Initialise the psLib time handling
     593        // XXX is this still needed / desired?
     594        psString timeName = psMetadataLookupStr(&mdok, config->complete, "TIME");
     595        if (mdok && timeName)
     596        {
     597            psTrace("psModules.config", 7, "Initialising psTime with file %s\n", timeName);
     598            psTimeInit(timeName);
     599        }
     600    }
    588601
    589602    // Next, we do a similar thing for the camera configuration file.  The
    590603    // file is read and parsed into psMetadata struct "camera".
    591     //
    592604    argNum = psArgumentGet(*argc, argv, "-camera");
    593605    if (argNum > 0) {
     
    600612            char *cameraName = argv[argNum]; // symbolic name of the camera
    601613
    602             // look for the CAMERAS list in config->site
    603             psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->site, "CAMERAS");
     614            // look for the CAMERAS list in config->complete
     615            psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->complete, "CAMERAS");
    604616            if (!cameras) {
    605617                psError(PS_ERR_IO, false, "Unable to find CAMERAS in site configuration.\n");
     
    647659                                  "Camera specified on command line", config->camera);
    648660
    649             if (!pmConfigCameraSkycellVersion(config->site, cameraName)) {
     661            if (!pmConfigCameraSkycellVersion(config->complete, cameraName)) {
    650662                psError(PS_ERR_UNKNOWN, false,
    651663                        "Unable to generate skycell versions of specified camera %s.\n",
     
    655667            }
    656668
    657             if (!pmConfigCameraMosaickedVersions(config->site, cameraName)) {
     669            if (!pmConfigCameraMosaickedVersions(config->complete, cameraName)) {
    658670                psError(PS_ERR_UNKNOWN, false,
    659671                        "Unable to generate mosaicked versions of specified camera %s.\n",
     
    668680    if (!config->camera && readCameraConfig) {
    669681        bool mdok;                      // Status of MD lookup
    670         psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->site, "CAMERAS"); // List of cameras
     682        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->complete, "CAMERAS"); // List of cameras
    671683        if (!mdok || !cameras) {
    672             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n");
     684            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
    673685            return false;
    674686        }
    675687
    676688        if (!metadataReadFiles(cameras, "camera configuration")) {
    677             psError(PS_ERR_UNKNOWN, false, "Unable to read cameras within site configuration.\n");
     689            psError(PS_ERR_UNKNOWN, false, "Unable to read cameras within system configuration.\n");
    678690            psFree(config);
    679691            return NULL;
     
    702714        psFree(iter);
    703715
    704         if (!pmConfigCameraSkycellVersionsAll(config->site)) {
     716        if (!pmConfigCameraSkycellVersionsAll(config->complete)) {
    705717            psError(PS_ERR_UNKNOWN, false, "Unable to generate skycell versions of cameras.\n");
    706718            psFree(config);
    707719            return NULL;
    708720        }
    709         if (!pmConfigCameraMosaickedVersionsAll(config->site)) {
     721        if (!pmConfigCameraMosaickedVersionsAll(config->complete)) {
    710722            psError(PS_ERR_UNKNOWN, false, "Unable to generate mosaicked versions of cameras.\n");
    711723            psFree(config);
     
    715727
    716728    // Load the recipes from the camera file, if appropriate
    717     if(!pmConfigReadRecipes(config, PM_RECIPE_SOURCE_SITE | PM_RECIPE_SOURCE_CAMERA)) {
     729    if(!pmConfigReadRecipes(config, PM_RECIPE_SOURCE_SYSTEM | PM_RECIPE_SOURCE_CAMERA)) {
    718730        psError(PS_ERR_IO, false, "Failed to read recipes from camera file");
    719731        psFree(config);
     
    746758        psArgumentRemove(argNum, argc, argv);
    747759
    748         psMetadata *cameras = psMetadataLookupMetadata(NULL, config->site, "CAMERAS"); // List of cameras
     760        psMetadata *cameras = psMetadataLookupMetadata(NULL, config->complete, "CAMERAS"); // List of cameras
    749761        if (!cameras) {
    750762            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find CAMERAS in the site configuration.\n");
     
    794806        } else {
    795807            char *dbserver = argv[argNum]; // The camera configuration file to read
    796             if (!psMetadataAddStr(config->site, PS_LIST_TAIL, "DBSERVER", PS_META_REPLACE, NULL, dbserver)) {
     808            if (!psMetadataAddStr(config->complete, PS_LIST_TAIL, "DBSERVER", PS_META_REPLACE, NULL, dbserver)) {
    797809                psWarning("Failed to overwrite .ipprc DBSERVER value");
    798810            }
     
    809821        } else {
    810822            char *dbname = argv[argNum]; // The camera configuration file to read
    811             if (!psMetadataAddStr(config->site, PS_LIST_TAIL, "DBNAME", PS_META_REPLACE, NULL, dbname)) {
     823            if (!psMetadataAddStr(config->complete, PS_LIST_TAIL, "DBNAME", PS_META_REPLACE, NULL, dbname)) {
    812824                psWarning("Failed to overwrite .ipprc DBNAME value");
    813825            }
     
    824836        } else {
    825837            char *dbuser = argv[argNum]; // The camera configuration file to read
    826             if (!psMetadataAddStr(config->site, PS_LIST_TAIL, "DBUSER", PS_META_REPLACE, NULL, dbuser)) {
     838            if (!psMetadataAddStr(config->complete, PS_LIST_TAIL, "DBUSER", PS_META_REPLACE, NULL, dbuser)) {
    827839                psWarning("Failed to overwrite .ipprc DBUSER value");
    828840            }
     
    839851        } else {
    840852            char *dbpassword = argv[argNum]; // The camera configuration file to read
    841             if (!psMetadataAddStr(config->site, PS_LIST_TAIL, "DBPASSWORD", PS_META_REPLACE,
     853            if (!psMetadataAddStr(config->complete, PS_LIST_TAIL, "DBPASSWORD", PS_META_REPLACE,
    842854                                  NULL, dbpassword)) {
    843855                psWarning("Failed to overwrite .ipprc DBPASSWORD value");
     
    855867        } else {
    856868            char *dbport = argv[argNum]; // The camera configuration file to read
    857             if (!psMetadataAddS32(config->site, PS_LIST_TAIL, "DBPORT", PS_META_REPLACE, NULL,
     869            if (!psMetadataAddS32(config->complete, PS_LIST_TAIL, "DBPORT", PS_META_REPLACE, NULL,
    858870                                  (psS32)atoi(dbport))) {
    859871                psWarning("Failed to overwrite .ipprc DBPORT value");
     
    10271039    if (! config->camera) {
    10281040        bool mdok;                      // Metadata lookup status
    1029         psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->site, "CAMERAS");
     1041        psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->complete, "CAMERAS");
    10301042        if (! mdok || !cameras) {
    10311043            psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration.");
     
    11141126    PS_ASSERT_STRING_NON_EMPTY(cameraName, NULL);
    11151127
    1116     psMetadata *cameras = psMetadataLookupMetadata(NULL, config->site, "CAMERAS");
     1128    psMetadata *cameras = psMetadataLookupMetadata(NULL, config->complete, "CAMERAS");
    11171129    if (!cameras) {
    11181130        psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration.");
     
    11401152{
    11411153    PS_ASSERT_PTR_NON_NULL(config, NULL);
    1142     PS_ASSERT_PTR_NON_NULL(config->site, NULL);
     1154    PS_ASSERT_PTR_NON_NULL(config->complete, NULL);
    11431155
    11441156    #ifndef HAVE_PSDB
     
    11571169
    11581170    // XXX leaky strings
    1159     psString dbServer = psMetadataLookupStr(&mdStatus01, config->site, "DBSERVER");
    1160     psString dbUsername = psMetadataLookupStr(&mdStatus02, config->site, "DBUSER");
    1161     psString dbPassword = psMetadataLookupStr(&mdStatus03, config->site, "DBPASSWORD");
    1162     psString dbName = psMetadataLookupStr(&mdStatus04, config->site, "DBNAME");
    1163     psS32 dbPort = psMetadataLookupS32(&mdStatus05, config->site, "DBPORT");
     1171    psString dbServer = psMetadataLookupStr(&mdStatus01, config->complete, "DBSERVER");
     1172    psString dbUsername = psMetadataLookupStr(&mdStatus02, config->complete, "DBUSER");
     1173    psString dbPassword = psMetadataLookupStr(&mdStatus03, config->complete, "DBPASSWORD");
     1174    psString dbName = psMetadataLookupStr(&mdStatus04, config->complete, "DBNAME");
     1175    psS32 dbPort = psMetadataLookupS32(&mdStatus05, config->complete, "DBPORT");
    11641176    if (!mdStatus05) {
    11651177        dbPort = 0;
     
    13521364    // replace path://PATH with matched datapath
    13531365    if (!strncasecmp(filename, "path://", strlen("path://"))) {
    1354         PS_ASSERT_METADATA_NON_NULL(config->site, NULL);
     1366        PS_ASSERT_METADATA_NON_NULL(config->complete, NULL);
    13551367
    13561368        psString newName = psStringCopy(filename);
    13571369
    13581370        // filename should be of the form: path://PATH/rest/of/file
    1359         // replace PATH with matching name from config->site:DATAPATH
    1360         psMetadata *datapath = psMetadataLookupPtr (NULL, config->site, "DATAPATH");
     1371        // replace PATH with matching name from config->complete:DATAPATH
     1372        psMetadata *datapath = psMetadataLookupPtr (NULL, config->complete, "DATAPATH");
    13611373        if (datapath == NULL) {
    13621374            psError(PS_ERR_UNKNOWN, true, "DATAPATH is not defined in config.site");
     
    14101422        // if env isn't set, check the config system
    14111423        if (!neb_server) {
    1412             neb_server = psMetadataLookupStr(&status, config->site, "NEB_SERVER");
     1424            neb_server = psMetadataLookupStr(&status, config->complete, "NEB_SERVER");
    14131425            if (!status) {
    14141426                psError(PM_ERR_CONFIG, true, "failed to lookup config value for NEB_SERVER.");
  • trunk/psModules/src/config/pmConfig.h

    r15385 r16611  
    55 *  @author Eugene Magnier, IfA
    66 *
    7  *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-10-26 02:41:15 $
     7 *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2008-02-22 20:20:38 $
    99 *  Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    2525typedef enum {
    2626    PM_RECIPE_SOURCE_NONE        = 0x00, ///< None yet
    27     PM_RECIPE_SOURCE_SITE        = 0x01, ///< Site configuration
     27    PM_RECIPE_SOURCE_SYSTEM      = 0x01, ///< System configuration
    2828    PM_RECIPE_SOURCE_CAMERA      = 0x02, ///< Camera configuration
    2929    PM_RECIPE_SOURCE_CL          = 0x04, ///< Command-line
     
    3434/// Configuration information
    3535///
    36 /// This structure stores the configuration information: the site, camera and recipe configuration, the
     36/// This structure stores the configuration information: user, site, system, camera and recipe configuration, the
    3737/// command-line arguments, the pmFPAfiles used, and the database handle.
    3838typedef struct {
    39     psMetadata *site;                   ///< Site configuration
     39    psMetadata *user;                   ///< User configuration
     40    psMetadata *site;                   ///< Site configuration
     41    psMetadata *system;                 ///< System configuration
     42    psMetadata *complete;               ///< Full merged configuration
    4043    psMetadata *camera;                 ///< Camera specification
    4144    psString cameraName;                ///< Camera name
     
    6871/// Read configuration information from the command line.
    6972///
    70 /// pmConfigRead loads the site configuration (the file name is specified by "-site SITE_FILE" on the
    71 /// command-line, the PS_SITE environment variable, or it is $HOME/.ipprc).  The configuration search path is
     73/// pmConfigRead loads the user configuration (the file name is specified by "-ipprc FILE" on the
     74/// command-line, the IPPRC environment variable, or it is $HOME/.ipprc).  The configuration search path is
    7275/// set. The camera configuration is loaded if it is specified on the command line ("-camera
    7376/// CAMERA_FILE"). Recipes specified on the command line ("-recipe RECIPE_NAME RECIPE_SOURCE") are also
    7477/// loaded.  These command-line arguments are removed from from the command-line, to simplify parsing.  The
    75 /// psLib log, trace and time setups are also performed if specified in the site configuration.
     78/// psLib log, trace and time setups are also performed if specified in the user configuration.
    7679pmConfig *pmConfigRead(int *argc,       ///< Number of command-line arguments
    7780                       char **argv, ///< Array of command-line arguments
     
    166169/// Get the file rule of interest
    167170///
    168 /// Look up the name of the set of file rules to use, get that set from the site configuration, and return the
     171/// Look up the name of the set of file rules to use, get that set from the system configuration, and return the
    169172/// appropriate rule from the set.
    170173psMetadata *pmConfigFileRule(const pmConfig *config, ///< Configuration
  • trunk/psModules/src/config/pmConfigCamera.c

    r15788 r16611  
    2424
    2525// Generate the skycell version of a named camera configuration
    26 bool pmConfigCameraSkycellVersion(psMetadata *site, // The site configuration
     26bool pmConfigCameraSkycellVersion(psMetadata *system, // The system configuration
    2727                                  const char *name // Name of the un-mosaicked camera
    2828                                  )
    2929{
    30     PS_ASSERT_METADATA_NON_NULL(site, false);
     30    PS_ASSERT_METADATA_NON_NULL(system, false);
    3131    PS_ASSERT_STRING_NON_EMPTY(name, false);
    3232
    3333    bool mdok;                          // Status of MD lookup
    34     psMetadata *cameras = psMetadataLookupMetadata(&mdok, site, "CAMERAS"); // List of cameras
     34    psMetadata *cameras = psMetadataLookupMetadata(&mdok, system, "CAMERAS"); // List of cameras
    3535    if (!mdok || !cameras) {
    36         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n");
    37         return false;
    38     }
    39     if (!pmConfigGenerateSkycellVersion(cameras, cameras, name, site)) {
     36        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
     37        return false;
     38    }
     39    if (!pmConfigGenerateSkycellVersion(cameras, cameras, name, system)) {
    4040        psError(PS_ERR_UNKNOWN, true, "Failed to build skycell camera description for %s\n", name);
    4141        return false;
     
    4545
    4646
    47 bool pmConfigCameraSkycellVersionsAll(psMetadata *site)
    48 {
    49     PS_ASSERT_METADATA_NON_NULL(site, false);
     47bool pmConfigCameraSkycellVersionsAll(psMetadata *system)
     48{
     49    PS_ASSERT_METADATA_NON_NULL(system, false);
    5050
    5151    bool mdok;                          // Status of MD lookup
    52     psMetadata *cameras = psMetadataLookupMetadata(&mdok, site, "CAMERAS"); // List of cameras
     52    psMetadata *cameras = psMetadataLookupMetadata(&mdok, system, "CAMERAS"); // List of cameras
    5353    if (!mdok || !cameras) {
    54         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n");
     54        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
    5555        return false;
    5656    }
     
    6161    while ((camerasItem = psMetadataGetAndIncrement(camerasIter))) {
    6262        assert(camerasItem->type == PS_DATA_METADATA); // Only metadata are allowed here!
    63         if (!pmConfigGenerateSkycellVersion(cameras, new, camerasItem->name, site)) {
     63        if (!pmConfigGenerateSkycellVersion(cameras, new, camerasItem->name, system)) {
    6464            psError(PS_ERR_UNKNOWN, true, "Failed to build skycell camera description for %s\n",
    6565                    camerasItem->name);
     
    9292static const char *skycellConceptName(const char *name, // Name of concept
    9393                                      const char **concepts, // List of concepts NOT to update
    94                                       const psMetadata *site // Site configuration
     94                                      const psMetadata *system // System configuration
    9595                                      )
    9696{
     
    101101    }
    102102
    103     if (!site) {
     103    if (!system) {
    104104        return name;
    105105    }
    106106    bool mdok;                          // Status of MD lookup
    107     psMetadata *skycells = psMetadataLookupMetadata(&mdok, site, "SKYCELLS"); // Skycell concept headers
     107    psMetadata *skycells = psMetadataLookupMetadata(&mdok, system, "SKYCELLS"); // Skycell concept headers
    108108    if (!skycells) {
    109109        return name;
     
    121121                                    psMetadata *newCameras, // New list of camera configurations
    122122                                    const char *name, // Name of original camera configuration
    123                                     const psMetadata *site // Site configuration
     123                                    const psMetadata *system // System configuration
    124124                                    )
    125125{
     
    213213        iter = psListIteratorAlloc(concepts, PS_LIST_HEAD, false);
    214214        while ((name = psListGetAndIncrement(iter))) {
    215             const char *new = skycellConceptName(name, skycellConceptsFPA, site); // Name for skycell
     215            const char *new = skycellConceptName(name, skycellConceptsFPA, system); // Name for skycell
    216216            if (new) {
    217217                psMetadataAddStr(translation, PS_LIST_TAIL, name, 0, NULL, new);
     
    224224        iter = psListIteratorAlloc(concepts, PS_LIST_HEAD, false);
    225225        while ((name = psListGetAndIncrement(iter))) {
    226             const char *new = skycellConceptName(name, skycellConceptsChip, site); // Name for skycell
     226            const char *new = skycellConceptName(name, skycellConceptsChip, system); // Name for skycell
    227227            if (new) {
    228228                psMetadataAddStr(translation, PS_LIST_TAIL, name, 0, NULL, new);
     
    235235        iter = psListIteratorAlloc(concepts, PS_LIST_HEAD, false);
    236236        while ((name = psListGetAndIncrement(iter))) {
    237             const char *new = skycellConceptName(name, skycellConceptsCell, site); // Name for skycell
     237            const char *new = skycellConceptName(name, skycellConceptsCell, system); // Name for skycell
    238238            if (new) {
    239239                psMetadataAddStr(translation, PS_LIST_TAIL, name, 0, NULL, new);
     
    299299
    300300// Generate the Chip and FPA mosaicked version of a named camera configuration
    301 bool pmConfigCameraMosaickedVersions(psMetadata *site, // The site configuration
     301bool pmConfigCameraMosaickedVersions(psMetadata *system, // The system configuration
    302302                                     const char *name // Name of the un-mosaicked camera
    303303                                    )
    304304{
    305     PS_ASSERT_METADATA_NON_NULL(site, false);
     305    PS_ASSERT_METADATA_NON_NULL(system, false);
    306306    PS_ASSERT_STRING_NON_EMPTY(name, false);
    307307
    308308    bool mdok;                          // Status of MD lookup
    309     psMetadata *cameras = psMetadataLookupMetadata(&mdok, site, "CAMERAS"); // List of cameras
     309    psMetadata *cameras = psMetadataLookupMetadata(&mdok, system, "CAMERAS"); // List of cameras
    310310    if (!mdok || !cameras) {
    311         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n");
     311        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
    312312        return false;
    313313    }
     
    325325// the operation putting the new entries first is now implemented in pmConfigGenerateMosaickedVersion
    326326// Generate the Chip and FPA mosaicked version of a named camera configuration
    327 bool pmConfigCameraMosaickedVersionsAll(psMetadata *site)
    328 {
    329     PS_ASSERT_METADATA_NON_NULL(site, false);
     327bool pmConfigCameraMosaickedVersionsAll(psMetadata *system)
     328{
     329    PS_ASSERT_METADATA_NON_NULL(system, false);
    330330
    331331    bool mdok;                          // Status of MD lookup
    332     psMetadata *cameras = psMetadataLookupMetadata(&mdok, site, "CAMERAS"); // List of cameras
     332    psMetadata *cameras = psMetadataLookupMetadata(&mdok, system, "CAMERAS"); // List of cameras
    333333    if (!mdok || !cameras) {
    334         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n");
     334        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
    335335        return false;
    336336    }
  • trunk/psModules/src/config/pmConfigCommand.c

    r12696 r16611  
    1212{
    1313    PS_ASSERT_PTR_NON_NULL(command, false);
     14    PS_ASSERT_PTR_NON_NULL(config, false);
     15    PS_ASSERT_PTR_NON_NULL(config->complete, false);
    1416
    1517    bool mdok;                          // Status of MD lookup
    16     const char *dbserver = psMetadataLookupStr(&mdok, config->site, "DBSERVER"); // Database server
     18    const char *dbserver = psMetadataLookupStr(&mdok, config->complete, "DBSERVER"); // Database server
    1719    if (!mdok || strlen(dbserver) == 0) {
    1820        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBSERVER in site configuration.\n");
    19         return NULL;
     21        return false;
    2022    }
    21     const char *dbname = psMetadataLookupStr(&mdok, config->site, "DBNAME"); // Database name
     23    const char *dbname = psMetadataLookupStr(&mdok, config->complete, "DBNAME"); // Database name
    2224    if (!mdok || strlen(dbname) == 0) {
    2325        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBNAME in site configuration.\n");
    24         return NULL;
     26        return false;
    2527    }
    26     const char *dbuser = psMetadataLookupStr(&mdok, config->site, "DBUSER"); // Database user
     28    const char *dbuser = psMetadataLookupStr(&mdok, config->complete, "DBUSER"); // Database user
    2729    if (!mdok || strlen(dbuser) == 0) {
    2830        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBUSER in site configuration.\n");
    29         return NULL;
     31        return false;
    3032    }
    31     const char *dbpassword = psMetadataLookupStr(&mdok, config->site, "DBPASSWORD"); // Database password
     33    const char *dbpassword = psMetadataLookupStr(&mdok, config->complete, "DBPASSWORD"); // Database password
    3234    if (!mdok || strlen(dbpassword) == 0) {
    3335        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find DBPASSWORD in site configuration.\n");
    34         return NULL;
     36        return false;
    3537    }
    3638
  • trunk/psModules/src/config/pmConfigRecipes.c

    r15727 r16611  
    1111#include "pmConfigRecipes.h"
    1212
    13 static bool loadRecipeSite(bool *status, pmConfig *config, psMetadata *source);
     13static bool loadRecipeSystem(bool *status, pmConfig *config, psMetadata *source);
    1414static bool loadRecipeCamera(bool *status, pmConfig *config, psMetadata *source);
    1515static bool loadRecipeFromArguments(bool *status, pmConfig *config);
     
    4646
    4747// this function may be called several times.  it attempts to load the recipe data from one of
    48 // three locations: config->site, config->camera, and argv.  We cannot read the recipes
     48// three locations: config->complete, config->camera, and argv.  We cannot read the recipes
    4949// from config->camera until a camera has been read BUT, the argv recipes must override the
    50 // camera and site recipes.
     50// camera and system recipes.
    5151bool pmConfigReadRecipes(pmConfig *config, pmRecipeSource source)
    5252{
     
    5858    }
    5959
    60     // Read the recipe file names from the site configuration and camera configuration
    61     // It is an error for config->site:recipes not to exist.  all programs install their
    62     // master recipe files in the site:recipe location when they are built.
    63     if (config->site && (source & PM_RECIPE_SOURCE_SITE)) {
    64         if (!loadRecipeSite(&status, config, config->site)) {
    65             psError(PS_ERR_IO, false, "Failed to read recipes from site config");
    66             return false;
    67         }
    68         psTrace ("psModules.config", 3, "read recipes from site config");
     60    // Read the recipe file names from the system configuration and camera configuration
     61    // It is an error for config->complete:recipes not to exist.  all programs install their
     62    // master recipe files in the system:recipe location when they are built.
     63    if (config->complete && (source & PM_RECIPE_SOURCE_SYSTEM)) {
     64        if (!loadRecipeSystem(&status, config, config->complete)) {
     65            psError(PS_ERR_IO, false, "Failed to read recipes from system config");
     66            return false;
     67        }
     68        psTrace ("psModules.config", 3, "read recipes from system config");
    6969    }
    7070
     
    283283}
    284284
    285 // Load the recipe files for SITE : REQUIRED
    286 static bool loadRecipeSite(bool *status,
     285// Load the recipe files for SYSTEM : REQUIRED
     286static bool loadRecipeSystem(bool *status,
    287287                           pmConfig *config, // The configuration into which to read the recipes
    288288                           psMetadata *source // The source configuration, from which to read the filenames
     
    294294
    295295    if (!source) {
    296         psError(PS_ERR_IO, true, "The site configuration has not been read --- cannot read recipes from this location.\n");
    297         config->recipesRead &= ~PM_RECIPE_SOURCE_SITE;
     296        psError(PS_ERR_IO, true, "The system configuration has not been read --- cannot read recipes from this location.\n");
     297        config->recipesRead &= ~PM_RECIPE_SOURCE_SYSTEM;
    298298        return false;
    299299    }
     
    301301    psMetadata *recipes = psMetadataLookupMetadata(NULL, source, "RECIPES"); // The list of recipes
    302302    if (!recipes) {
    303         psError(PS_ERR_IO, false, "RECIPES not found in the site configuration\n");
     303        psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n");
    304304        return false;
    305305    }
     
    313313        // type mismatch is a serious error
    314314        if (fileItem->type != PS_DATA_STRING) {
    315             psError(PS_ERR_IO, true, "%s in site configuration RECIPES is not of type STR", fileItem->name);
     315            psError(PS_ERR_IO, true, "%s in system configuration RECIPES is not of type STR", fileItem->name);
    316316            return false;
    317317        }
     
    320320        psMetadata *recipe = NULL;
    321321        if (!pmConfigFileRead(&recipe, fileItem->data.str, "recipe")) {
    322             psError(PS_ERR_IO, false, "Failed to read recipe file %s listed in site configuration\n",
     322            psError(PS_ERR_IO, false, "Failed to read recipe file %s listed in system configuration\n",
    323323                    fileItem->data.str);
    324324            return false;
     
    331331    }
    332332    psFree(recipesIter);
    333     config->recipesRead |= PM_RECIPE_SOURCE_SITE;
     333    config->recipesRead |= PM_RECIPE_SOURCE_SYSTEM;
    334334
    335335    *status = true;
     
    337337}
    338338
    339 // Load the recipe files (valid for SITE | CAMERA)
     339// Load the recipe files (valid for SYSTEM | CAMERA)
    340340// each time we load a specific recipe, it overrides the existing metadata for that recipe
    341 // for sourceType == SITE | CAMERA, RECIPES contains a list of files to be read (pmConfigFileRead)
     341// for sourceType == SYSTEM | CAMERA, RECIPES contains a list of files to be read (pmConfigFileRead)
    342342static bool loadRecipeCamera(bool *status, // status variable
    343343                             pmConfig *config, // The configuration into which to read the recipes
  • trunk/psModules/src/detrend/pmDetrendDB.c

    r15911 r16611  
    115115    PS_ASSERT_PTR_NON_NULL(options, NULL);
    116116    PS_ASSERT_PTR_NON_NULL(config, NULL);
    117     PS_ASSERT_PTR_NON_NULL(config->site, NULL);
    118117
    119118    int status, exit_status;
     
    150149        psStringAppend(&line, " -airmass %f", options->twilight);
    151150    }
    152 
    153     pmConfigDatabaseCommand(&line, config);
    154     pmConfigTraceCommand(&line);
     151   
     152    if (!pmConfigDatabaseCommand(&line, config)) {
     153        psError (PS_ERR_IO, false, "error building detrend command %s", line);
     154        goto failure;
     155    }
     156
     157    if (!pmConfigTraceCommand(&line)) {
     158        psError (PS_ERR_IO, false, "error building detrend command %s", line);
     159        goto failure;
     160    }
     161
    155162    psTrace("psModules.detrend", 5, "running %s", line);
    156163
  • trunk/psphot/src/psphotOutput.c

    r16250 r16611  
    1919}
    2020
     21// XXX replace this with a call to a pmConfig function (pmConfigDump...)
    2122bool psphotDumpConfig (pmConfig *config) {
    2223
    23   psMetadataConfigWrite (config->site, "site.md");
     24  psMetadataConfigWrite (config->complete, "complete.md");
    2425  psMetadataConfigWrite (config->camera, "camera.md");
    2526  psMetadataConfigWrite (config->recipes, "recipes.md");
  • trunk/pswarp/src/pswarpDefineSkycell.c

    r12717 r16611  
    6262    // determine the current format from the header
    6363    // determine camera if not specified already
     64    // XXX EAM : this operation should be defined as a pmConfig function (pmConfigCopy?)
    6465    skyConfig = pmConfigAlloc(0, NULL);
    65     skyConfig->site = psMemIncrRefCounter (config->site);
     66    skyConfig->complete = psMemIncrRefCounter (config->complete);
     67
    6668    psFree (skyConfig->files);
    6769    skyConfig->files = psMemIncrRefCounter (config->files);
Note: See TracChangeset for help on using the changeset viewer.