Changeset 6705 for branches/1.7/src


Ignore:
Timestamp:
Jan 4, 2019 3:14:36 PM (4 years ago)
Author:
clarksm
Message:

Enable "ionhelper" to execute jobs and immediately put results in cache.
This includes reporting run.xml location with absolute path.

Location:
branches/1.7/src/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.7/src/core/RpLibrary.cc

    r6313 r6705  
    2828#include <iterator>
    2929#include <cctype>
     30#include <limits.h>
     31#include <unistd.h>
    3032
    3133#ifdef _POSIX_SOURCE
     
    20482050    }
    20492051    if ((compress == RPLIB_COMPRESS) ||
    2050         (Rappture::encoding::isBinary(fileBuf.bytes(), fileBuf.size()))) {     
     2052        (Rappture::encoding::isBinary(fileBuf.bytes(), fileBuf.size()))) {
    20512053        putData(path, fileBuf.bytes(), fileBuf.size(), append);
    20522054    } else {
     
    22272229    struct tm* timeinfo;
    22282230    std::stringstream outputFile;
     2231    char currentWorkingDirectory[PATH_MAX+1];
     2232    char *cwd;
    22292233    std::string timestamp;
    22302234    std::string username;
     
    22332237
    22342238    if (this->root == NULL) {
    2235         return;                         /* No tree available */
    2236     }
    2237 
    2238     t = time(NULL);                     /* This is presumably the time the
    2239                                         * simulation finished. */
     2239        return;            /* No tree available */
     2240    }
     2241
     2242    t = time(NULL);        /* This is presumably the time the
     2243                            * simulation finished. */
    22402244#ifdef HAVE_GETTIMEOFDAY
    22412245    /* If the posix function gettimeofday is available, use it to produce
     
    22472251    outputFile << "run" << (int)t << ".xml";
    22482252#endif
     2253    // get current working directory
     2254    cwd = getcwd(currentWorkingDirectory,PATH_MAX);
     2255
    22492256    file.open(outputFile.str().c_str(),std::ios::out);
    22502257   
     
    22532260    put("tool.version.rappture.revision", SVN_VERSION);
    22542261    put("tool.version.rappture.modified",
    2255         "$LastChangedDate$");
     2262        "$LastChangedDate$");
    22562263    if ( "" == get("tool.version.rappture.language") ) {
    2257         put("tool.version.rappture.language","c++");
     2264        put("tool.version.rappture.language","c++");
    22582265    }
    22592266    // generate a timestamp for the run file
     
    22702277    user = getenv("USERNAME");
    22712278    if (user != NULL) {
    2272         username = std::string(user);
     2279        username = std::string(user);
    22732280    } else {
    2274         user = getenv("LOGNAME");
    2275         if (user != NULL) {
    2276             username = std::string(user);
    2277         }
     2281        user = getenv("LOGNAME");
     2282        if (user != NULL) {
     2283            username = std::string(user);
     2284        }
    22782285    }
    22792286#else
     
    22812288    user = getenv("USER");
    22822289    if (user != NULL) {
    2283         username = std::string(user);
     2290        username = std::string(user);
    22842291    } else {
    2285         user = getenv("LOGNAME");
    2286         if (user != NULL) {
    2287             username = std::string(user);
    2288         }
     2292        user = getenv("LOGNAME");
     2293        if (user != NULL) {
     2294            username = std::string(user);
     2295        }
    22892296    }
    22902297#endif
     
    22972304   
    22982305    if ( file.is_open() ) {
    2299         xmlText = xml();
    2300         if (!xmlText.empty()) {
    2301             file << xmlText;
    2302         }
    2303         // check to make sure there were no
    2304         // errors while writing the run.xml file.
    2305         if (   (!file.good())
    2306                || ((long)xmlText.length() != ((long)file.tellp()-(long)1))
    2307                ) {
    2308             status.error("Error while writing run file");
    2309             status.addContext("RpLibrary::result()");
    2310         }
    2311         file.close();
     2306        xmlText = xml();
     2307        if (!xmlText.empty()) {
     2308            file << xmlText;
     2309        }
     2310        // check to make sure there were no
     2311        // errors while writing the run.xml file.
     2312        if (   (!file.good()) || ((long)xmlText.length() != ((long)file.tellp()-(long)1))) {
     2313            status.error("Error while writing run file");
     2314            status.addContext("RpLibrary::result()");
     2315        }
     2316        file.close();
    23122317    } else {
    2313         status.error("Error while opening run file");
    2314         status.addContext("RpLibrary::result()");
    2315     }
    2316     std::cout << "=RAPPTURE-RUN=>" << outputFile.str() << std::endl;
     2318        status.error("Error while opening run file");
     2319        status.addContext("RpLibrary::result()");
     2320    }
     2321    if ( cwd != NULL ) {
     2322        std::string currentDirectory(currentWorkingDirectory);
     2323        std::cout << "=RAPPTURE-RUN=>" << outputFile.str() << "/" << currentDirectory << std::endl;
     2324    } else {
     2325        std::cout << "=RAPPTURE-RUN=>" << outputFile.str() << std::endl;
     2326    }
    23172327}
    23182328
  • branches/1.7/src/core/RpResult.cc

    r5679 r6705  
    1919#include <RpLibrary.h>
    2020#include <errno.h>
     21#include <limits.h>
     22#include <unistd.h>
    2123
    2224void
     
    2426{
    2527    char outputFile[100];
     28    char currentWorkingDirectory[PATH_MAX+1];
     29    char *cwd;
    2630    std::string xtext;
    2731    FILE* fp;
     
    2933
    3034    xtext = lib->xml();
     35
     36    // get current working directory
     37    cwd = getcwd(currentWorkingDirectory,PATH_MAX);
    3138
    3239    // create output filename
     
    4249    if (fsize != (int)xtext.length()) {
    4350        fprintf(stderr, "short write: can't save results: %s\n",
    44                 strerror(errno));
     51        strerror(errno));
    4552        fclose(fp);
    4653        return;
     
    4855    fclose(fp);
    4956    // tell Rappture the file name
    50     printf("=RAPPTURE-RUN=>%s\n", outputFile);
     57    if (cwd != NULL) {
     58        printf("=RAPPTURE-RUN=>%s/%s\n", currentWorkingDirectory, outputFile);
     59    } else {
     60        printf("=RAPPTURE-RUN=>%s\n", outputFile);
     61    }
    5162}
Note: See TracChangeset for help on using the changeset viewer.