Changeset 27083
- Timestamp:
- Feb 25, 2010, 12:01:24 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfig.c (modified) (53 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfig.c
r27060 r27083 178 178 char *envName = envStart + 1; // Start of the environment variable name 179 179 if (envName[0] == '\0') { 180 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Path %s contains a bad environment variable.\n", dir);180 psError(PM_ERR_CONFIG, true, "Path %s contains a bad environment variable.\n", dir); 181 181 return NULL; 182 182 } … … 184 184 envName++; 185 185 if (envName[0] == '\0') { 186 psError(P S_ERR_BAD_PARAMETER_VALUE, true,186 psError(PM_ERR_CONFIG, true, 187 187 "Path %s contains a bad environment variable.\n", dir); 188 188 return NULL; … … 276 276 277 277 if (configPath == NULL) { 278 psError(P S_ERR_IO, true, "Cannot find %s configuration file (%s) in path\n", description, name);278 psError(PM_ERR_CONFIG, true, "Cannot find %s configuration file (%s) in path\n", description, name); 279 279 return false; 280 280 } … … 300 300 } 301 301 302 psError(P S_ERR_IO, true, "Cannot find %s configuration file %s in path\n", description, name);302 psError(PM_ERR_CONFIG, true, "Cannot find %s configuration file %s in path\n", description, name); 303 303 return false; 304 304 … … 306 306 *config = psMetadataConfigRead(NULL, &numBadLines, realName, true); 307 307 if (numBadLines > 0) { 308 psError(P S_ERR_IO, false, "%d bad lines in %s configuration file (%s)",308 psError(PM_ERR_CONFIG, false, "%d bad lines in %s configuration file (%s)", 309 309 numBadLines, description, realName); 310 310 psFree (realName); … … 313 313 } 314 314 if (!*config) { 315 psError(P S_ERR_IO, true, "Unable to read %s configuration from %s",315 psError(PM_ERR_CONFIG, true, "Unable to read %s configuration from %s", 316 316 description, realName); 317 317 psFree (realName); … … 332 332 } 333 333 if (item->type != PS_DATA_STRING) { 334 ps Trace("config", 2, "Element %s in %s metadata is not of type STR.\n",334 psError(PM_ERR_CONFIG, true, "Element %s in %s metadata is not of type STR.\n", 335 335 item->name, description); 336 336 return false; … … 340 340 psMetadata *new = NULL; // New metadata 341 341 if (!pmConfigFileRead(&new, item->data.str, item->name)) { 342 psError( PM_ERR_CONFIG, false, "Trouble reading reading %s %s.\n",342 psError(psErrorCodeLast(), false, "Trouble reading reading %s %s.\n", 343 343 description, item->name); 344 344 psFree(new); … … 365 365 while ((item = psMetadataGetAndIncrement(iter))) { 366 366 if (!pmConfigFileIngest(item, description)) { 367 psError( PM_ERR_CONFIG, false, "Unable to read %s %s.", description, item->name);367 psError(psErrorCodeLast(), false, "Unable to read %s %s.", description, item->name); 368 368 psFree(iter); 369 369 return false; … … 386 386 psMetadata *formats = psMetadataLookupMetadata(&mdok, camera, "FORMATS"); // Formats 387 387 if (!mdok || !formats) { 388 psError(P S_ERR_UNEXPECTED_NULL, true, "Unable to find FORMATS in camera configuration %s.\n", name);388 psError(PM_ERR_CONFIG, true, "Unable to find FORMATS in camera configuration %s.\n", name); 389 389 return false; 390 390 } 391 391 if (!metadataReadFiles(formats, "camera format")) { 392 psError( PS_ERR_UNKNOWN, false, "Unable to read formats within camera configuration %s.\n", name);392 psError(psErrorCodeLast(), false, "Unable to read formats within camera configuration %s.\n", name); 393 393 return false; 394 394 } … … 490 490 psMetadataItem *siteItem = psMetadataLookup(config->user, "SITE"); 491 491 if (!siteItem) { 492 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find SITE in user configuration.");492 psError(PM_ERR_CONFIG, true, "Unable to find SITE in user configuration."); 493 493 psFree(config); 494 494 return NULL; 495 495 } 496 496 if (!pmConfigFileIngest(siteItem, "site configuration")) { 497 psError( PS_ERR_UNKNOWN, false, "Unable to read site configuration");497 psError(psErrorCodeLast(), false, "Unable to read site configuration"); 498 498 psFree(config); 499 499 return NULL; … … 504 504 psMetadataItem *systemItem = psMetadataLookup(config->user, "SYSTEM"); 505 505 if (!systemItem) { 506 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find SYSTEM in user configuration.");506 psError(PM_ERR_CONFIG, true, "Unable to find SYSTEM in user configuration."); 507 507 psFree(config); 508 508 return NULL; 509 509 } 510 510 if (!pmConfigFileIngest(systemItem, "system configuration")) { 511 psError( PS_ERR_UNKNOWN, false, "Unable to read system configuration");511 psError(psErrorCodeLast(), false, "Unable to read system configuration"); 512 512 psFree(config); 513 513 return NULL; … … 665 665 seed = strtoll(argv[argNum], &end, 0); 666 666 if (strlen(end) > 0) { 667 psError(PS_ERR_IO, true, "Unable to read random number generator seed: %s", argv[argNum]); 667 psError(PM_ERR_CONFIG, true, "Unable to read random number generator seed: %s", 668 argv[argNum]); 668 669 psFree(config); 669 670 return NULL; … … 690 691 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); 691 692 if (!cameras) { 692 psError(P S_ERR_IO, false, "Unable to find CAMERAS in site configuration.\n");693 psError(PM_ERR_CONFIG, false, "Unable to find CAMERAS in site configuration.\n"); 693 694 psFree(config); 694 695 return NULL; … … 698 699 char *cameraFile = psMetadataLookupStr(&mdok, cameras, cameraName); // The filename 699 700 if (!cameraFile) { 700 psError(P S_ERR_IO, false, "%s is not listed in the site CAMERAS list\n", cameraName);701 psError(PM_ERR_CONFIG, false, "%s is not listed in the site CAMERAS list\n", cameraName); 701 702 psFree(config); 702 703 return NULL; … … 705 706 // load this camera's configuration informatoin 706 707 if (!pmConfigFileRead(&config->camera, cameraFile, "camera")) { 707 psError( PM_ERR_CONFIG, false, "Problem reading %s", cameraName);708 psError(psErrorCodeLast(), false, "Problem reading %s", cameraName); 708 709 psFree(config); 709 710 return NULL; … … 716 717 // Read in the formats 717 718 if (!cameraReadFormats(config->camera, cameraFile)) { 718 psError( PS_ERR_UNKNOWN, false, "Unable to read formats within camera configuration %s.\n",719 psError(psErrorCodeLast(), false, "Unable to read formats within camera configuration %s.\n", 719 720 cameraFile); 720 721 psFree(config); … … 724 725 // Read in any camera-specific calibrations 725 726 if (!cameraReadCalibrations(config->camera, cameraName)) { 726 psError( PS_ERR_UNKNOWN, false,727 psError(psErrorCodeLast(), false, 727 728 "Unable to read calibrations within camera configuration %s.\n", 728 729 cameraName); … … 735 736 736 737 if (!pmConfigCameraSkycellVersion(config->system, cameraName)) { 737 psError( PS_ERR_UNKNOWN, false,738 psError(psErrorCodeLast(), false, 738 739 "Unable to generate skycell versions of specified camera %s.\n", 739 740 cameraName); … … 743 744 744 745 if (!pmConfigCameraMosaickedVersions(config->system, cameraName)) { 745 psError( PS_ERR_UNKNOWN, false,746 psError(psErrorCodeLast(), false, 746 747 "Unable to generate mosaicked versions of specified camera %s.\n", 747 748 cameraName); … … 757 758 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); // List of cameras 758 759 if (!mdok || !cameras) { 759 psError(P S_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");760 psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the system configuration.\n"); 760 761 return false; 761 762 } 762 763 763 764 if (!metadataReadFiles(cameras, "camera configuration")) { 764 psError( PS_ERR_UNKNOWN, false, "Unable to read cameras within system configuration.\n");765 psError(psErrorCodeLast(), false, "Unable to read cameras within system configuration.\n"); 765 766 psFree(config); 766 767 return NULL; … … 790 791 791 792 if (!pmConfigCameraSkycellVersionsAll(config->system)) { 792 psError( PS_ERR_UNKNOWN, false, "Unable to generate skycell versions of cameras.\n");793 psError(psErrorCodeLast(), false, "Unable to generate skycell versions of cameras.\n"); 793 794 psFree(config); 794 795 return NULL; 795 796 } 796 797 if (!pmConfigCameraMosaickedVersionsAll(config->system)) { 797 psError( PS_ERR_UNKNOWN, false, "Unable to generate mosaicked versions of cameras.\n");798 psError(psErrorCodeLast(), false, "Unable to generate mosaicked versions of cameras.\n"); 798 799 psFree(config); 799 800 return NULL; … … 803 804 // Load the recipes from the camera file, if appropriate 804 805 if(!pmConfigReadRecipes(config, PM_RECIPE_SOURCE_SYSTEM | PM_RECIPE_SOURCE_CAMERA)) { 805 psError( PS_ERR_IO, false, "Failed to read recipes from camera file");806 psError(psErrorCodeLast(), false, "Failed to read recipes from camera file"); 806 807 psFree(config); 807 808 return NULL; … … 818 819 819 820 if (!pmConfigReadRecipes(config, PM_RECIPE_SOURCE_CL)) { 820 psError( PS_ERR_IO, false, "Failed to read recipes from command-line");821 psError(psErrorCodeLast(), false, "Failed to read recipes from command-line"); 821 822 psFree(config); 822 823 return NULL; … … 827 828 psArgumentRemove(argNum, argc, argv); 828 829 if (argNum + 1 >= *argc) { 829 psError(P S_ERR_BAD_PARAMETER_SIZE, true,830 psError(PM_ERR_CONFIG, true, 830 831 "Filerule switch (-F) provided without old and new filerule."); 831 832 psFree(config); … … 840 841 psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // List of cameras 841 842 if (!cameras) { 842 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find CAMERAS in the site configuration.\n");843 psError(PM_ERR_CONFIG, false, "Unable to find CAMERAS in the site configuration.\n"); 843 844 return false; 844 845 } … … 1001 1002 psMetadata *rule = psMetadataLookupMetadata(&mdStatus, cameraFormat, "RULE"); 1002 1003 if (! mdStatus || ! rule) { 1003 psError(P S_ERR_UNKNOWN, false, "Unable to read rule for camera.");1004 psError(PM_ERR_CONFIG, false, "Unable to read rule for camera."); 1004 1005 *valid = false; 1005 1006 return false; … … 1010 1011 psArray *keys = psListToArray (keyList); 1011 1012 if (! keys) { 1012 psError(P S_ERR_UNKNOWN, false, "Unable to read rule for camera.");1013 psError(PM_ERR_CONFIG, false, "Unable to read rule for camera."); 1013 1014 *valid = false; 1014 1015 return false; … … 1059 1060 } 1060 1061 1061 psError(P S_ERR_UNKNOWN, false, "Invalid type for RULE %s.", ruleItem->name);1062 psError(PM_ERR_CONFIG, false, "Invalid type for RULE %s.", ruleItem->name); 1062 1063 *valid = false; 1063 1064 psFree (keyList); … … 1094 1095 psMetadata *formats = psMetadataLookupMetadata(&mdok, camera, "FORMATS"); // List of formats 1095 1096 if (!mdok || !formats) { 1096 psError(P S_ERR_UNKNOWN, false, "Unable to find list of FORMATS in camera %s", cameraName);1097 psError(PM_ERR_CONFIG, false, "Unable to find list of FORMATS in camera %s", cameraName); 1097 1098 *status = false; 1098 1099 return false; … … 1100 1101 1101 1102 if (!metadataReadFiles(formats, "camera format")) { 1102 psError( PS_ERR_UNKNOWN, false, "Unable to read cameras formats within camera configuration.\n");1103 psError(psErrorCodeLast(), false, "Unable to read cameras formats within camera configuration.\n"); 1103 1104 *status = false; 1104 1105 return false; … … 1116 1117 bool valid = false; 1117 1118 if (!pmConfigValidateCameraFormat(&valid, testFormat, header)) { 1118 psError ( PS_ERR_UNKNOWN, false, "Error in config scripts for camera %s, format %s\n",1119 psError (psErrorCodeLast(), false, "Error in config scripts for camera %s, format %s\n", 1119 1120 cameraName, formatsItem->name); 1120 1121 *status = false; … … 1162 1163 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); 1163 1164 if (! mdok || !cameras) { 1164 psError(P S_ERR_IO, true, "Unable to find CAMERAS in the configuration.");1165 psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the configuration."); 1165 1166 return NULL; 1166 1167 } 1167 1168 1168 1169 if (!metadataReadFiles(cameras, "camera configuration")) { 1169 psError( PS_ERR_UNKNOWN, false, "Unable to read cameras within site configuration.\n");1170 psError(psErrorCodeLast(), false, "Unable to read cameras within site configuration.\n"); 1170 1171 return NULL; 1171 1172 } … … 1196 1197 } else { 1197 1198 if (!status) { 1198 psError(PS_ERR_IO, false, "Error reading camera config data for %s", camerasItem->name); 1199 psError(psErrorCodeLast(), false, "Error reading camera config data for %s", 1200 camerasItem->name); 1199 1201 return NULL; 1200 1202 } … … 1205 1207 // Done looking at all cameras 1206 1208 if (!config->camera) { 1207 psError(P S_ERR_IO, false, "Unable to find a camera that matches input FITS header!");1209 psError(PM_ERR_CONFIG, true, "Unable to find a camera that matches input FITS header!"); 1208 1210 return NULL; 1209 1211 } … … 1211 1213 // Now we have the camera, we can read the recipes 1212 1214 if (readRecipes && !pmConfigReadRecipes(config, PM_RECIPE_SOURCE_CAMERA | PM_RECIPE_SOURCE_CL)) { 1213 psError(PS_ERR_IO, false, "Error reading recipes from camera config for %s", config->cameraName); 1215 psError(psErrorCodeLast(), false, "Error reading recipes from camera config for %s", 1216 config->cameraName); 1214 1217 return NULL; 1215 1218 } … … 1287 1290 1288 1291 if (!found) { 1289 psError(PS_ERR_IO, true, "Unable to find a format with the specified camera (%s) that matches the " 1290 "given header.\n", baseName); 1292 psError(PM_ERR_CONFIG, true, 1293 "Unable to find a format with the specified camera (%s) that matches the given header.", 1294 baseName); 1291 1295 psFree (baseName); 1292 1296 return NULL; … … 1319 1323 psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); 1320 1324 if (!cameras) { 1321 psError(P S_ERR_IO, true, "Unable to find CAMERAS in the configuration.");1325 psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the configuration."); 1322 1326 return NULL; 1323 1327 } … … 1325 1329 psMetadataItem *item = psMetadataLookup(cameras, cameraName); // Item with camera of interest 1326 1330 if (!pmConfigFileIngest(item, "camera configuration")) { 1327 psError( PS_ERR_UNKNOWN, false, "Unable to ingest camera configuration.");1331 psError(psErrorCodeLast(), false, "Unable to ingest camera configuration."); 1328 1332 return NULL; 1329 1333 } … … 1341 1345 item = psMetadataLookup(config->site, name); 1342 1346 if (!item) { 1343 psError(P S_ERR_BAD_PARAMETER_VALUE, true,1347 psError(PM_ERR_CONFIG, true, 1344 1348 "Unable to find %s in user or site configuration", name); 1345 1349 return NULL; … … 1347 1351 } 1348 1352 if (item->type != type) { 1349 psError(P S_ERR_BAD_PARAMETER_TYPE, true,1353 psError(PM_ERR_CONFIG, true, 1350 1354 "Type of %s (%x) in user/site configuration does not match expected (%x)", 1351 1355 name, item->type, type); … … 1364 1368 #ifndef HAVE_PSDB 1365 1369 1366 psError(P S_ERR_UNKNOWN, false,1370 psError(PM_ERR_PROG, false, 1367 1371 "Cannot configure database: psModules was compiled without database support."); 1368 1372 return NULL; … … 1413 1417 psMetadata *rules = psMetadataLookupMetadata(&mdok, format, "RULE"); // How to identify this format 1414 1418 if (!mdok || !rules) { 1415 psError(P S_ERR_IO, true, "Unable to find RULE in camera format.\n");1419 psError(PM_ERR_CONFIG, true, "Unable to find RULE in camera format.\n"); 1416 1420 return false; 1417 1421 } … … 1421 1425 while ((rulesItem = psMetadataGetAndIncrement(rulesIter))) { 1422 1426 if (!PS_DATA_IS_PRIMITIVE(rulesItem->type) && rulesItem->type != PS_DATA_STRING) { 1423 psError(P S_ERR_UNKNOWN, false, "Invalid type for RULE %s.", rulesItem->name);1427 psError(PM_ERR_CONFIG, false, "Invalid type for RULE %s.", rulesItem->name); 1424 1428 return false; 1425 1429 } … … 1453 1457 case PS_METADATA_ITEM_COMPARE_OP_NE: 1454 1458 // It's not at all obvious what the value should be, so return an error. 1455 psError(P S_ERR_IO, true,1459 psError(PM_ERR_CONFIG, true, 1456 1460 "RULE %s (defined by an OPeration) is not present or not consistent in output header", 1457 1461 rulesItem->name); … … 1536 1540 default: 1537 1541 // rigid format, no comments allowed? 1538 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to parse file list: spaces detected.");1542 psError(PM_ERR_CONFIG, true, "Unable to parse file list: spaces detected."); 1539 1543 psFree(input); 1540 1544 fclose(f); … … 1569 1573 if (!files) { 1570 1574 psAbort("error parsing argument list"); 1571 psError( PS_ERR_IO, false, "error parsing argument list");1575 psError(psErrorCodeLast(), false, "error parsing argument list"); 1572 1576 psFree (files); 1573 1577 return false; … … 1624 1628 psMetadata *datapath = psMetadataLookupPtr (NULL, config->site, "DATAPATH"); 1625 1629 if (datapath == NULL) { 1626 psError(P S_ERR_UNKNOWN, true, "DATAPATH is not defined in config.site");1630 psError(PM_ERR_CONFIG, true, "DATAPATH is not defined in config.site"); 1627 1631 psFree (newName); 1628 1632 return NULL; … … 1632 1636 char *mark = strchr (point, '/'); 1633 1637 if (mark == NULL) { 1634 psError(P S_ERR_UNKNOWN, true, "syntax error in PATH-style name %s", newName);1638 psError(PM_ERR_CONFIG, true, "syntax error in PATH-style name %s", newName); 1635 1639 psFree (newName); 1636 1640 return false; … … 1640 1644 char *realpath = psMetadataLookupStr (NULL, datapath, path); 1641 1645 if (realpath == NULL) { 1642 psError(P S_ERR_UNKNOWN, true,1646 psError(PM_ERR_CONFIG, true, 1643 1647 "path (%s) not defined in config.site:DATAPATH for PATH-style name %s", 1644 1648 path, newName); … … 1656 1660 if (!checkPath(newName, create, trunc)) { 1657 1661 // let checkPath()'s psError() call float up 1658 psError( PS_ERR_UNKNOWN, false, "error from checkPath for path:// (%s)", newName);1662 psError(psErrorCodeLast(), false, "error from checkPath for path:// (%s)", newName); 1659 1663 psFree (newName); 1660 1664 return NULL; … … 1747 1751 psMetadataItem *item = psMetadataLookup(camera, "FILERULES"); // Item with the file rule of interest 1748 1752 if (!item) { 1749 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find FILERULES in the camera configuration.");1753 psError(PM_ERR_CONFIG, false, "Unable to find FILERULES in the camera configuration."); 1750 1754 return NULL; 1751 1755 } … … 1780 1784 psMetadataItem *item = psMetadataLookup(camera, "FITSTYPES"); // Item with the file rule of interest 1781 1785 if (!item) { 1782 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find FITSTYPES in the camera configuration.");1786 psError(PM_ERR_CONFIG, false, "Unable to find FITSTYPES in the camera configuration."); 1783 1787 return NULL; 1784 1788 }
Note:
See TracChangeset
for help on using the changeset viewer.
