IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28110


Ignore:
Timestamp:
May 26, 2010, 11:58:13 AM (16 years ago)
Author:
Paul Price
Message:

Pulling in fixes from trunk required for warptool -advancerun and pstamp operations.

Location:
tags/ipp-20100525
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20100525/dbconfig

  • tags/ipp-20100525/dbconfig/changes.txt

    r28096 r28110  
    17121712) ENGINE=innodb DEFAULT CHARSET=latin1;
    17131713
     1714CREATE TABLE pstampWebRequest (
     1715        num BIGINT AUTO_INCREMENT,
     1716        PRIMARY KEY(num)
     1717) ENGINE=innodb DEFAULT CHARSET=latin1;
     1718
  • tags/ipp-20100525/dbconfig/pstamp.md

    r27874 r28110  
    5959    fault       S16         0
    6060END
     61
     62pstampWebRequest METADATA
     63    num         S64         0    # Primary Key AUTO_INCREMENT
     64END
  • tags/ipp-20100525/ippTools

  • tags/ipp-20100525/ippTools/share/pxadmin_create_tables.sql

    r28096 r28110  
    14011401) ENGINE=innodb DEFAULT CHARSET=latin1;
    14021402
     1403CREATE TABLE pstampWebRequest (
     1404        num BIGINT AUTO_INCREMENT,
     1405        PRIMARY KEY(num)
     1406) ENGINE=innodb DEFAULT CHARSET=latin1;
     1407
    14031408CREATE TABLE distTarget (
    14041409    target_id   BIGINT AUTO_INCREMENT,
  • tags/ipp-20100525/ippTools/share/pxadmin_drop_tables.sql

    r27856 r28110  
    8585DROP TABLE IF EXISTS staticskyRun;
    8686DROP TABLE IF EXISTS Label;
     87DROP TABLE IF EXISTS pstampWebRequest;
    8788
    8889SET FOREIGN_KEY_CHECKS=1
  • tags/ipp-20100525/ippTools/src/pstamptool.c

    r27969 r28110  
    5353static bool updatedependentMode(pxConfig *config);
    5454static bool revertdependentMode(pxConfig *config);
     55static bool getwebrequestnumMode(pxConfig *config);
    5556
    5657# define MODECASE(caseName, func) \
     
    9596        MODECASE(PSTAMPTOOL_MODE_UPDATEDEPENDENT, updatedependentMode);
    9697        MODECASE(PSTAMPTOOL_MODE_REVERTDEPENDENT, revertdependentMode);
     98        MODECASE(PSTAMPTOOL_MODE_GETWEBREQUESTNUM, getwebrequestnumMode);
    9799        default:
    98100            psAbort("invalid option (this should not happen)");
     
    13341336    return true;
    13351337}
     1338
     1339static bool getwebrequestnumMode(pxConfig *config)
     1340{
     1341    PS_ASSERT_PTR_NON_NULL(config, false);
     1342
     1343    if (!pstampWebRequestInsert(config->dbh, 0 )) {
     1344        psError(PS_ERR_UNKNOWN, false, "failed to insert pstampWebRequest");
     1345        return false;
     1346    }
     1347
     1348    psS64 req_id = psDBLastInsertID(config->dbh);
     1349
     1350    printf("%" PRId64 "\n", req_id);
     1351
     1352    return true;
     1353}
  • tags/ipp-20100525/ippTools/src/pstamptool.h

    r27874 r28110  
    4848    PSTAMPTOOL_MODE_UPDATEDEPENDENT,
    4949    PSTAMPTOOL_MODE_REVERTDEPENDENT,
     50    PSTAMPTOOL_MODE_GETWEBREQUESTNUM,
    5051} pstamptoolMode;
    5152
  • tags/ipp-20100525/ippTools/src/pstamptoolConfig.c

    r27874 r28110  
    235235    psMetadataAddBool(projectArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
    236236
     237    // -getwebrequestnum
     238    psMetadata *getwebrequestnumArgs = psMetadataAlloc();
     239
    237240    psMetadata *argSets = psMetadataAlloc();
    238241    psMetadata *modes = psMetadataAlloc();
     
    264267    PXOPT_ADD_MODE("-modproject",      "", PSTAMPTOOL_MODE_MODPROJECT, modprojectArgs);
    265268    PXOPT_ADD_MODE("-project",         "", PSTAMPTOOL_MODE_PROJECT,    projectArgs);
     269    PXOPT_ADD_MODE("-getwebrequestnum","", PSTAMPTOOL_MODE_GETWEBREQUESTNUM,   getwebrequestnumArgs);
    266270
    267271    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
  • tags/ipp-20100525/ippTools/src/pxtools.c

    r28091 r28110  
    4848}
    4949
    50 psString pxMergeCodeVersions(psString version1, psString version2) {
     50psString pxMergeCodeVersions(psString version1, psString version2)
     51{
     52    if (!version1 && !version2) {
     53        return NULL;
     54    }
     55
     56    if (!version1) {
     57        return psStringCopy(version2);
     58    }
     59    if (!version2) {
     60        return psStringCopy(version1);
     61    }
     62
     63    bool mod1 = false, mod2 = false;    // Modified versions?
     64    if (strchr(version1, 'M')) {
     65        psStringSubstitute(&version1, "M", "");
     66        mod1 = true;
     67    }
     68    if (strchr(version2, 'M')) {
     69        psStringSubstitute(&version2, "M", "");
     70        mod2 = true;
     71    }
     72
     73    int num1 = strtol(version1, NULL, 10);
     74    int num2 = strtol(version2, NULL, 10);
     75    int numO = PS_MAX(num1, num2);
     76
    5177    psString out = NULL;
    52 
    53     bool mod1 = false;
    54     bool mod2 = false;
    55 
    56     psS32 num1;
    57     psS32 num2;
    58     psS32 numO;
    59 
    60     if (!version1) {
    61         psStringAppend(&out, "%s", version2);
    62         return(out);
    63     }
    64     if (!version2) {
    65         psStringAppend(&out, "%s", version1);
    66         return(out);
    67     }
    68  
    69     if (strchr(version1,'M')) {
    70         psStringSubstitute(&version1,"M","");
    71         mod1 = true;
    72     }
    73     if (strchr(version2,'M')) {
    74         psStringSubstitute(&version2,"M","");
    75         mod2 = true;
    76     }
    77 
    78     num1 = strtol(version1,NULL,10);
    79     num2 = strtol(version2,NULL,10);
    80 
    81     if (num1 >= num2) {
    82         numO = num1;
    83     }
    84     else {
    85         numO = num2;
    86     }
    87  
    88     psStringAppend(&out,"%" PRId32,numO);
     78    psStringAppend(&out, "%" PRId32, numO);
    8979    if (mod1 || mod2) {
    90         psStringAppend(&out,"M");
    91     }
    92     return(out);
     80        psStringAppend(&out, "M");
     81    }
     82    return out;
    9383}
    9484
    9585bool pxCoalesceRunStatus(pxConfig *config, const psString dbQFile, psS64 stage_id, psString *software_ver,
    96                          psS64 *maskfrac_npix, psF32 *maskfrac_static, psF32 *maskfrac_dynamic,
    97                          psF32 *maskfrac_magic, psF32 *maskfrac_advisory) {
     86                         psS64 *maskfrac_npix, psF32 *maskfrac_static, psF32 *maskfrac_dynamic,
     87                         psF32 *maskfrac_magic, psF32 *maskfrac_advisory)
     88{
    9889    psString query = pxDataGet(dbQFile);
    99 /*   psString text_id = NULL; */
    100 /*   psStringAppend(&text_id," %" PRId64,stage_id); */
    101 /*   psStringSubstitute(&query,text_id,"@STAGE_ID@"); */
    102 /*   psFree(text_id); */
     90    if (!query) {
     91        psError(psErrorCodeLast(), false, "Unable to read query");
     92        return false;
     93    }
    10394    if (!p_psDBRunQueryF(config->dbh, query, stage_id)) {
    104         psError(PS_ERR_UNKNOWN, false, "database error");
    105         psFree(query);
    106         return(false);
     95        psError(psErrorCodeLast(), false, "database error");
     96        psFree(query);
     97        return false;
    10798    }
    10899    psFree(query);
     100
    109101    psArray *output = p_psDBFetchResult(config->dbh);
    110102    if (!output) {
    111         psError(PS_ERR_UNKNOWN, false, "database error");
    112         return(false);
    113     }
    114  
     103        psError(psErrorCodeLast(), false, "database error");
     104        return false;
     105    }
     106
     107    *maskfrac_npix = 0;
     108    *maskfrac_static = 0.0;
     109    *maskfrac_dynamic = 0.0;
     110    *maskfrac_magic = 0.0;
     111    *maskfrac_advisory = 0.0;
     112
    115113    for (long i = 0; i < psArrayLength(output); i++) {
    116         psMetadata *row = output->data[i];
    117 
    118         psS32 this_npix = psMetadataLookupS32(NULL, row, "maskfrac_npix");
    119         psF32 this_static = psMetadataLookupF32(NULL, row, "maskfrac_static");
    120         psF32 this_dynamic = psMetadataLookupF32(NULL, row, "maskfrac_dynamic");
    121         psF32 this_magic = psMetadataLookupF32(NULL, row, "maskfrac_magic");
    122         psF32 this_advisory = psMetadataLookupF32(NULL, row, "maskfrac_advisory");
    123         psString this_version = psMetadataLookupStr(NULL, row, "software_ver");
    124 
    125         *software_ver = pxMergeCodeVersions(*software_ver,this_version);
    126 /*     printf("%ld : %d %f %f %f %f <-> %ld %f %f %f %f\n",i,this_npix,this_static,this_dynamic,this_magic,this_advisory, */
    127 /*         *maskfrac_npix,*maskfrac_static,*maskfrac_dynamic,*maskfrac_magic,*maskfrac_advisory); */
    128         if (this_npix > 0) {
    129             *maskfrac_static = ((*maskfrac_static * *maskfrac_npix) + (this_npix * this_static)) / (this_npix + *maskfrac_npix);
    130             *maskfrac_dynamic = ((*maskfrac_dynamic * *maskfrac_npix) + (this_npix * this_dynamic)) / (this_npix + *maskfrac_npix);
    131             *maskfrac_magic = ((*maskfrac_magic * *maskfrac_npix) + (this_npix * this_magic)) / (this_npix + *maskfrac_npix);
    132             *maskfrac_advisory = ((*maskfrac_advisory * *maskfrac_npix) + (this_npix * this_advisory)) / (this_npix + *maskfrac_npix);
    133             *maskfrac_npix += this_npix;
    134         }
     114        psMetadata *row = output->data[i];
     115
     116        psS32 this_npix = psMetadataLookupS32(NULL, row, "maskfrac_npix");
     117        psF32 this_static = psMetadataLookupF32(NULL, row, "maskfrac_static");
     118        psF32 this_dynamic = psMetadataLookupF32(NULL, row, "maskfrac_dynamic");
     119        psF32 this_magic = psMetadataLookupF32(NULL, row, "maskfrac_magic");
     120        psF32 this_advisory = psMetadataLookupF32(NULL, row, "maskfrac_advisory");
     121
     122        psTrace("pxtools", 3, "Mask stats: %d %f %f %f %f\n",
     123                this_npix, this_static, this_dynamic, this_magic, this_advisory);
     124
     125        if (this_npix == 0 || this_npix == PS_MAX_S32) {
     126            continue;
     127        }
     128        if (!isfinite(this_static) || !isfinite(this_dynamic) ||
     129            !isfinite(this_magic) || !isfinite(this_advisory)) {
     130            continue;
     131        }
     132
     133        psString this_version = psMetadataLookupStr(NULL, row, "software_ver");
     134        *software_ver = pxMergeCodeVersions(*software_ver,this_version);
     135
     136        *maskfrac_npix += this_npix;
     137        *maskfrac_static += this_npix * this_static;
     138        *maskfrac_dynamic += this_npix * this_dynamic;
     139        *maskfrac_magic += this_npix * this_magic;
     140        *maskfrac_advisory += this_npix * this_advisory;
    135141    }
    136142    psFree(output);
    137     return(true);
    138 }
    139 
    140 bool pxSetRunSoftware(pxConfig *config, const psString tableName, const psString stage_id_name, const psS64 stage_id,
    141                       psString software_ver) {
     143
     144    if (*maskfrac_npix > 0) {
     145        *maskfrac_static /= *maskfrac_npix;
     146        *maskfrac_dynamic /= *maskfrac_npix;
     147        *maskfrac_magic /= *maskfrac_npix;
     148        *maskfrac_advisory /= *maskfrac_npix;
     149    }
     150
     151    return true;
     152}
     153
     154bool pxSetRunSoftware(pxConfig *config, const psString tableName, const psString stage_id_name,
     155                      const psS64 stage_id, psString software_ver)
     156{
    142157    char *query = "UPDATE %s SET software_ver = '%s' WHERE %s = %" PRId64;
    143 /*   printf(query,tableName,software_ver,stage_id_name,stage_id); */
    144     if (!p_psDBRunQueryF(config->dbh,query,tableName,software_ver,stage_id_name,stage_id)) {
    145         psError(PS_ERR_UNKNOWN, false,
    146                 "failed to set software version for %s %" PRId64,stage_id_name,stage_id);
    147         return(false);
    148     }
    149  
    150     return(true);
    151 }
    152 
    153 bool pxSetRunMaskfrac(pxConfig *config, const psString tableName, const psString stage_id_name, const psS64 stage_id,
    154                       psS64 maskfrac_npix, psF32 maskfrac_static, psF32 maskfrac_dynamic,
    155                       psF32 maskfrac_magic, psF32 maskfrac_advisory) {
    156     char *query = "UPDATE %s SET maskfrac_npix = %f, maskfrac_static = %f, maskfrac_dynamic = %f, maskfrac_magic = %f, maskfrac_advisory = %f WHERE %s = %" PRId64;
    157     if (!p_psDBRunQueryF(config->dbh,query,tableName,(float) maskfrac_npix,maskfrac_static,
    158                          maskfrac_dynamic, maskfrac_magic,maskfrac_advisory,stage_id_name,stage_id)) {
    159         psError(PS_ERR_UNKNOWN, false,
    160                 "failed to set maskfrac stats for %s %" PRId64,stage_id_name,stage_id);
    161         return(false);
    162     }
    163  
    164 
    165 
    166     return(true);
    167 }
    168 
    169 bool pxCamSetRunMaskfrac(pxConfig *config, const psString tableName, const psString stage_id_name, const psS64 stage_id,
    170                          psS64 maskfrac_ref_npix, psF32 maskfrac_ref_static, psF32 maskfrac_ref_dynamic,
    171                          psF32 maskfrac_ref_magic, psF32 maskfrac_ref_advisory,
    172                          psS64 maskfrac_max_npix, psF32 maskfrac_max_static, psF32 maskfrac_max_dynamic,
    173                          psF32 maskfrac_max_magic, psF32 maskfrac_max_advisory) {
    174   char *query = "UPDATE %s SET maskfrac_ref_npix = %f, maskfrac_ref_static = %f, maskfrac_ref_dynamic = %f, maskfrac_ref_magic = %f, maskfrac_ref_advisory = %f, maskfrac_max_npix = %f, maskfrac_max_static = %f, maskfrac_max_dynamic = %f, maskfrac_max_magic = %f, maskfrac_max_advisory = %f WHERE %s = %" PRId64;
    175   if (!p_psDBRunQueryF(config->dbh,query,tableName,(float) maskfrac_ref_npix,maskfrac_ref_static,
    176                        maskfrac_ref_dynamic, maskfrac_ref_magic,maskfrac_ref_advisory,
    177                        (float) maskfrac_max_npix,maskfrac_max_static,
    178                        maskfrac_max_dynamic, maskfrac_max_magic,maskfrac_max_advisory,
    179                        stage_id_name,stage_id)) {
    180     psError(PS_ERR_UNKNOWN, false,
    181             "failed to set maskfrac stats for %s %" PRId64,stage_id_name,stage_id);
    182     return(false);
     158    if (!p_psDBRunQueryF(config->dbh, query, tableName, software_ver, stage_id_name, stage_id)) {
     159        psError(psErrorCodeLast(), false,
     160                "failed to set software version for %s %" PRId64, stage_id_name, stage_id);
     161        return false;
     162    }
     163
     164    return true;
     165}
     166
     167bool pxSetRunMaskfrac(pxConfig *config, const psString tableName, const psString stage_id_name,
     168                      const psS64 stage_id, psS64 maskfrac_npix, psF32 maskfrac_static,
     169                      psF32 maskfrac_dynamic, psF32 maskfrac_magic, psF32 maskfrac_advisory)
     170{
     171    char *query = "UPDATE %s SET maskfrac_npix = %f, maskfrac_static = %f, maskfrac_dynamic = %f, "
     172        "maskfrac_magic = %f, maskfrac_advisory = %f WHERE %s = %" PRId64;
     173    if (!p_psDBRunQueryF(config->dbh, query, tableName, (float)maskfrac_npix, maskfrac_static,
     174                         maskfrac_dynamic, maskfrac_magic, maskfrac_advisory, stage_id_name, stage_id)) {
     175        psError(psErrorCodeLast(), false,
     176                "failed to set maskfrac stats for %s %" PRId64,stage_id_name,stage_id);
     177        return false;
     178    }
     179
     180
     181
     182    return true;
     183}
     184
     185bool pxCamSetRunMaskfrac(pxConfig *config, const psString tableName,
     186                         const psString stage_id_name, const psS64 stage_id,
     187                         psS64 maskfrac_ref_npix, psF32 maskfrac_ref_static, psF32 maskfrac_ref_dynamic,
     188                         psF32 maskfrac_ref_magic, psF32 maskfrac_ref_advisory,
     189                         psS64 maskfrac_max_npix, psF32 maskfrac_max_static, psF32 maskfrac_max_dynamic,
     190                         psF32 maskfrac_max_magic, psF32 maskfrac_max_advisory) {
     191  char *query = "UPDATE %s SET maskfrac_ref_npix = %f, maskfrac_ref_static = %f, maskfrac_ref_dynamic = %f, "
     192      "maskfrac_ref_magic = %f, maskfrac_ref_advisory = %f, maskfrac_max_npix = %f, maskfrac_max_static = %f, "
     193      "maskfrac_max_dynamic = %f, maskfrac_max_magic = %f, maskfrac_max_advisory = %f WHERE %s = %" PRId64;
     194  if (!p_psDBRunQueryF(config->dbh, query, tableName, (float)maskfrac_ref_npix, maskfrac_ref_static,
     195                       maskfrac_ref_dynamic,  maskfrac_ref_magic, maskfrac_ref_advisory,
     196                       (float)maskfrac_max_npix, maskfrac_max_static,
     197                       maskfrac_max_dynamic,  maskfrac_max_magic, maskfrac_max_advisory,
     198                       stage_id_name, stage_id)) {
     199      psError(psErrorCodeLast(), false,
     200              "failed to set maskfrac stats for %s %" PRId64,stage_id_name,stage_id);
     201      return false;
    183202  }
    184  
    185 
    186 
    187   return(true);
     203
     204  return true;
    188205}
    189206
     
    222239    psMetadataItem *item = psMetadataLookup(config->args, name);
    223240    if (!item) {
    224         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for %s", name);
     241        psError(psErrorCodeLast(), false, "failed to lookup value for %s", name);
    225242        return false;
    226243    }
     
    239256            item->comment = psStringCopy (op);
    240257            if (!psMetadataAddItem(where, item, PS_LIST_TAIL, PS_META_DUPLICATE_OK)) {
    241                 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", field);
     258                psError(psErrorCodeLast(), false, "failed to add item %s", field);
    242259                psFree(where);
    243260                return false;
     
    293310    char *comma = ",";
    294311
    295 #   define addColumn(_tab, _val)                                        \
    296     do {                                                                \
    297         if (_val) {                                                     \
    298             psStringAppend(pQuery, "%s %s.%s = '%s'", separator, _tab, #_val, _val); \
    299             separator = comma;                                          \
    300         }                                                               \
     312#   define addColumn(_tab, _val)                                        \
     313    do {                                                                \
     314        if (_val) {                                                     \
     315            psStringAppend(pQuery, "%s %s.%s = '%s'", separator, _tab, #_val, _val); \
     316            separator = comma;                                          \
     317        }                                                               \
    301318    } while (0)
    302319
     
    331348
    332349    if (!p_psDBRunQueryF(config->dbh, *pQuery, joinHook)) {
    333         psError(PS_ERR_UNKNOWN, false, "database error");
     350        psError(psErrorCodeLast(), false, "database error");
    334351        return false;
    335352    }
     
    343360
    344361    if (!p_psDBRunQuery(config->dbh, query)) {
    345         psError(PS_ERR_UNKNOWN, false, "database error");
     362        psError(psErrorCodeLast(), false, "database error");
    346363        return false;
    347364    }
     
    349366    psArray *output = p_psDBFetchResult(config->dbh);
    350367    if (!output) {
    351         psError(PS_ERR_UNKNOWN, false, "database error");
     368        psError(psErrorCodeLast(), false, "database error");
    352369        return false;
    353370    }
    354371    if (!psArrayLength(output)) {
    355372        psFree(output);
    356         psError(PS_ERR_UNKNOWN, true, "no rows in dbversion");
     373        psError(PXTOOLS_ERR_PROG, true, "no rows in dbversion");
    357374        return false;
    358375    }
    359376    if (psArrayLength(output) > 1) {
    360         psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found in dbversion: %ld",
     377        psError(PXTOOLS_ERR_PROG, true, "unexpected number of rows found in dbversion: %ld",
    361378                psArrayLength(output));
    362379        return false;
     
    373390    psArray *array = NULL;
    374391    if (!pxLookupVersion(config, &array)) {
    375         psError(PS_ERR_UNKNOWN, false, "pxLookupVersion failed");
     392        psError(psErrorCodeLast(), false, "pxLookupVersion failed");
    376393        return NULL;
    377394    }
    378395    psMetadata *md = array->data[0];
    379396    if (!md) {
    380         psError(PS_ERR_UNKNOWN, true, "output of pxLookupVersion is null");
     397        psError(PXTOOLS_ERR_PROG, true, "output of pxLookupVersion is null");
    381398        return NULL;
    382399    }
     
    394411    psArray *array = NULL;
    395412    if (!pxLookupVersion(config, &array) || !array) {
    396         psError(PS_ERR_UNKNOWN, false, "pxLookupVersion failed");
     413        psError(psErrorCodeLast(), false, "pxLookupVersion failed");
    397414        return false;
    398415    }
    399416    if (!ippdbPrintMetadatas(file, array, "dbversion", true)) {
    400         psError(PS_ERR_UNKNOWN, false, "failed to print array");
     417        psError(psErrorCodeLast(), false, "failed to print array");
    401418        psFree(array);
    402419        return false;
     
    414431    psMetadataItem *multi_item =  psMetadataLookup(input, "dbversion");
    415432    if (!multi_item || (multi_item->type != PS_DATA_METADATA_MULTI)) {
    416         psError(PS_ERR_UNKNOWN, true, "dbversion multi not found in input");
     433        psError(PXTOOLS_ERR_PROG, true, "dbversion multi not found in input");
    417434        return false;
    418435    }
     
    420437    psMetadataItem *dbversion = psListGet(multi_item->data.list, 0);
    421438    if (!dbversion) {
    422         psError(PS_ERR_UNKNOWN, true, "dbversion not found in input");
     439        psError(PXTOOLS_ERR_PROG, true, "dbversion not found in input");
    423440        return false;
    424441    }
     
    429446        psString schema_version = pxGetDBVersion(config);
    430447        if (!schema_version) {
    431             psError(PS_ERR_UNKNOWN, false, "pxGetDBVersion failed");
     448            psError(psErrorCodeLast(), false, "pxGetDBVersion failed");
    432449            return false;
    433450        }
     
    435452        psString import_version = psMetadataLookupStr(NULL, md, "schema_version");
    436453        if (import_version && strcmp(import_version, schema_version)) {
    437             psError(PS_ERR_UNKNOWN, true, "input file schema_version: %s does not match data base: %s",
    438                     import_version, schema_version);
     454            psError(PXTOOLS_ERR_PROG, true, "input file schema_version: %s does not match data base: %s",
     455                    import_version, schema_version);
    439456            return false;
    440457        } else if (!import_version) {
    441             psError(PS_ERR_UNKNOWN, true, "input file schema_version is NULL");
     458            psError(PXTOOLS_ERR_PROG, true, "input file schema_version is NULL");
    442459            return false;
    443460        } else {
     
    445462        }
    446463    } else {
    447         psError(PS_ERR_UNKNOWN, true, "Unexpected config dump format");
    448         return false;
    449     }
    450 
    451     return true;
    452 }
     464        psError(PXTOOLS_ERR_PROG, true, "Unexpected config dump format");
     465        return false;
     466    }
     467
     468    return true;
     469}
  • tags/ipp-20100525/pstamp

  • tags/ipp-20100525/pstamp/scripts/pstamp_insert_request.pl

    r27211 r28110  
    114114
    115115exit 0;
    116 
    117 # Temporary hack
    118 # webrequest number is stored in a file in the current directory
    119 #
    120 # get this number from the database
     116# Ask the database for the next web request number
    121117sub get_webreq_num
    122118{
    123     my $filename = "$workdir/webreq_num.txt";
    124     if (! open IN, "+< $filename" ) {
    125         my $initial_num = 1;
    126         open IN, "> $filename" or die "can't open $filename";
    127         print IN "$initial_num\n" or die "failed to initialize $filename";
    128         close IN;
    129         return $initial_num;
     119    my $command = "$pstamptool -getwebrequestnum";
     120    $command .= " -dbname $dbname" if $dbname;
     121    $command .= " -dbserver $dbserver" if $dbserver;
     122    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     123        run(command => $command, verbose => $verbose);
     124    unless ($success) {
     125        print STDERR @$stderr_buf;
     126        die("Unable to perform pstamptool -getwebrequestnum: $error_code");
     127    }
     128    my $webreq_num = ${$stdout_buf}[0];
     129    chomp $webreq_num;
     130
     131    if (!$webreq_num) {
     132        die("pstamptool -getwebreqnum returned no value");
    130133    }
    131134
    132     my $webreq_num = <IN>;
    133     chomp $webreq_num;
     135    # print STDERR "webreq_num $webreq_num\n";
    134136
    135     print STDERR "$webreq_num\n" if $verbose;
    136 
    137     my $next = $webreq_num + 1;
    138     truncate IN, 0;
    139     seek IN, 0, 0;
    140     print IN "$next\n";
    141 
    142     close IN;
    143137    return $webreq_num;
    144138}
  • tags/ipp-20100525/pstamp/scripts/pstamp_webrequest.pl

    r27355 r28110  
    2323
    2424my $host = hostname();
    25 my $verbose = 0;
     25my $verbose = 1;
    2626my $dbname;
    2727my $dbserver;
     
    152152exit 0;
    153153
    154 # Temporary hack
    155 # webrequest number is stored in a file in the current directory
    156 #
     154# Ask the database for the next web request number
    157155sub get_webreq_num
    158156{
    159     my $filename = "webreq_num.txt";
    160     if (! open IN, "+< $filename" ) {
    161         my $initial_num = 1;
    162         open IN, "> $filename" or die "can't open $filename";
    163         print IN "$initial_num\n" or die "failed to initialize $filename";
    164         close IN;
    165         return $initial_num;
     157    my $command = "$pstamptool -getwebrequestnum";
     158    $command .= " -dbname $dbname" if $dbname;
     159    $command .= " -dbserver $dbserver" if $dbserver;
     160    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     161        run(command => $command, verbose => $verbose);
     162    unless ($success) {
     163        print STDERR @$stderr_buf;
     164        die("Unable to perform pstamptool -getwebrequestnum: $error_code");
     165    }
     166    my $webreq_num = ${$stdout_buf}[0];
     167    chomp $webreq_num;
     168
     169    if (!$webreq_num) {
     170        die("pstamptool -getwebreqnum returned no value");
    166171    }
    167172
    168     my $webreq_num = <IN>;
    169     chomp $webreq_num;
     173    # print STDERR "webreq_num $webreq_num\n";
    170174
    171     print STDERR "$webreq_num\n" if $verbose;
    172 
    173     my $next = $webreq_num + 1;
    174     truncate IN, 0;
    175     seek IN, 0, 0;
    176     print IN "$next\n";
    177 
    178     close IN;
    179175    return $webreq_num;
    180176}
Note: See TracChangeset for help on using the changeset viewer.