IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 2, 2006, 3:02:08 PM (20 years ago)
Author:
Paul Price
Message:

Applying RHL patch. Generally improves the error handling and traceback. pmConcepts.c and pmConceptsRead.c done by PAP (RHL did this also, but I had already done them). Resolved conflicts, except for pmFPAfile.c, which uses psAbort in some instances where RHL's patch had psError; leave this for Gene to decide.

File:
1 edited

Legend:

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

    r7278 r7311  
    33 *  @author PAP, IfA
    44 *
    5  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-06-02 00:55:22 $
     5 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-06-03 01:02:08 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1212#include <string.h>
    1313#include <unistd.h>
     14#include <libgen.h>
    1415#include <assert.h>
    1516#include <sys/types.h>
     
    5253}
    5354
     55void pmConfigSet(const char *path)
     56{
     57    pmConfigDone();
     58
     59    psList *list = psStringSplit(path, ":", false);
     60    configPath = psListToArray(list);
     61    psFree(list);
     62}
     63
    5464void pmConfigDone(void)
    5565{
    5666    psFree(configPath);
     67    configPath = NULL;
    5768}
    5869
     
    100111
    101112    if (configPath == NULL) {
    102         psError(PS_ERR_IO, false, "Cannot find %s configuration file (%s) in path\n", description, name);
     113        psError(PS_ERR_IO, true, "Cannot find %s configuration file (%s) in path\n", description, name);
    103114        return false;
    104115    }
     
    121132    }
    122133
    123     psError(PS_ERR_IO, false, "Cannot find %s configuration file %s in path\n", description, name);
     134    psError(PS_ERR_IO, true, "Cannot find %s configuration file %s in path\n", description, name);
    124135    return false;
    125136
     
    127138    *config = psMetadataConfigParse(NULL, &numBadLines, realName, true);
    128139    if (numBadLines > 0) {
    129         psLogMsg(__func__, PS_LOG_WARN, "%d bad lines in %s configuration file (%s)\n",
    130                  description, realName);
     140        psError(PS_ERR_IO, false, "%d bad lines in %s configuration file (%s)",
     141                numBadLines, description, realName);
     142        psFree (realName);
     143
     144        return false;
    131145    }
    132146    if (!*config) {
    133         psError(PS_ERR_IO, false, "Unable to read %s configuration from %s\n",
     147        psError(PS_ERR_IO, true, "Unable to read %s configuration from %s",
    134148                description, realName);
    135149        psFree (realName);
     
    214228        return NULL;
    215229    }
     230
     231    // define the config-file search path (configPath).  Ensure that
     232    // it contains the directory where we found the config file in
     233    // the first place
     234    if (configPath) {
     235        pmConfigDone();
     236    }
     237
     238    psString siteNameDir = psStringCopy(dirname(siteName));
    216239    psFree(siteName);
    217240
    218     // define the config-file search path (configPath)
    219     if (configPath) {
    220         psFree(configPath);
    221         configPath = NULL;
    222     }
    223     char *path = psMetadataLookupStr(NULL, config->site, "PATH");
     241    psString path = psMetadataLookupStr(NULL, config->site, "PATH");
    224242    if (path) {
    225         psList *list = psStringSplit(path, ":", false);
    226         configPath = psListToArray(list);
    227         psFree(list);
    228     }
     243        psStringAppend(&path, ":%s", siteNameDir);
     244    } else {
     245        path = psMemIncrRefCounter(siteNameDir);
     246    }
     247    pmConfigSet(path);
     248    psFree(siteNameDir);
    229249
    230250    // Next, we do a similar thing for the camera configuration file.  The
     
    349369    }
    350370
     371    psErrorClear();   // we may have failed to find some items in the metadata
     372
    351373    return config;
    352374}
     
    468490        psMetadata *cameras = psMetadataLookupMD(&mdok, config->site, "CAMERAS");
    469491        if (! mdok) {
    470             psError(PS_ERR_IO, false, "Unable to find CAMERAS in the configuration.\n");
     492            psError(PS_ERR_IO, true, "Unable to find CAMERAS in the configuration.");
    471493            return false;
    472494        }
     
    502524
    503525        if (! config->camera) {
    504             psError(PS_ERR_IO, true, "Unable to find a camera that matches input FITS header!\n");
     526            psError(PS_ERR_IO, false, "Unable to find a camera that matches input FITS header!");
    505527            return NULL;
    506528        }
     
    611633    psMetadata *rules = psMetadataLookupMD(&mdok, format, "RULE"); // How to identify this format
    612634    if (!mdok || !rules) {
    613         psError(PS_ERR_IO, false, "Unable to find RULE in camera format.\n");
     635        psError(PS_ERR_IO, true, "Unable to find RULE in camera format.\n");
    614636        return false;
    615637    }
     
    651673        globList.gl_offs = 0;
    652674        glob (argv[Narg], 0, NULL, &globList);
     675
     676        if (globList.gl_pathc == 0) {
     677            psError(PS_ERR_IO, true, "No match for %s", argv[Narg]);
     678            return input;
     679        }
     680
    653681        for (int i = 0; i < globList.gl_pathc; i++) {
    654682            char *filename = psStringCopy (globList.gl_pathv[i]);
     
    706734    PS_ASSERT_INT_POSITIVE(strlen(list), NULL);
    707735
     736    psErrorClear();   // pmConfigFileSets may or may not call psError, so
     737    // if files->n == 0 we'll want to call psError(..., false, ...)
    708738    psArray *files = pmConfigFileSets (argc, argv, file, list);
    709739    if (files->n == 0) {
     740        psError(PS_ERR_IO, false, "pmConfigFileSets failed to find desired files in metadata");
    710741        psFree (files);
    711742        return false;
Note: See TracChangeset for help on using the changeset viewer.