Changeset 2381 for trunk/packages


Ignore:
Timestamp:
Aug 16, 2011, 9:22:50 AM (13 years ago)
Author:
gah
Message:
 
Location:
trunk/packages/vizservers
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanoscale/server2.c

    r2377 r2381  
    2323
    2424#define ERROR(...)      LogMessage(LOG_ERR, __FILE__, __LINE__, __VA_ARGS__)
    25 #ifdef WANT_TRACE
    2625#define TRACE(...)      LogMessage(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
    27 #else
    28 #define TRACE(...)
    29 #endif
    3026#define WARN(...)       LogMessage(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__)
    3127#define INFO(...)       LogMessage(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r2380 r2381  
    22502250    NanoVis::stdin = stdin;
    22512251
    2252     if ((n = write(1, "NanoVis ", 8)) != 8) {
    2253        INFO("short write %d", n);
    2254     }
     2252    fprintf(stdout, "NanoVis %s\n", NANOVIS_VERSION);
     2253    fflush(stdout);
     2254
    22552255    /* openlog("nanovis", LOG_CONS | LOG_PERROR | LOG_PID,  LOG_USER); */
    2256     INFO("writing marker to stdout");
    22572256    gettimeofday(&tv, NULL);
    22582257    stats.start = tv;
  • trunk/packages/vizservers/nanovis/nanovis.h

    r2096 r2381  
    6868#include "config.h"
    6969
     70#define NANOVIS_VERSION         "1.0"
    7071
    7172//defines for the image based flow visualization
  • trunk/packages/vizservers/pymolproxy/pymolproxy.c

    r2373 r2381  
    6767#include <sys/wait.h>
    6868#include <time.h>
     69#include <syslog.h>
    6970#include <unistd.h>
    7071#include <tcl.h>
     
    173174} PymolProxy;
    174175
     176#define ERROR(...)      LogMessage(LOG_ERR, __FILE__, __LINE__, __VA_ARGS__)
     177#define TRACE(...)      LogMessage(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
     178#define WARN(...)       LogMessage(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__)
     179#define INFO(...)       LogMessage(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
     180
     181static const char *syslogLevels[] = {
     182    "emergency",                        /* System is unusable */
     183    "alert",                            /* Action must be taken immediately */
     184    "critical",                         /* Critical conditions */
     185    "error",                            /* Error conditions */
     186    "warning",                          /* Warning conditions */
     187    "notice",                           /* Normal but significant condition */
     188    "info",                             /* Informational */
     189    "debug",                            /* Debug-level messages */
     190};
     191
     192void
     193LogMessage(int priority, const char *path, int lineNum, const char* fmt, ...)
     194{
     195#define MSG_LEN (2047)
     196    char message[MSG_LEN+1];
     197    const char *s;
     198    int length;
     199    va_list lst;
     200
     201    va_start(lst, fmt);
     202    s = strrchr(path, '/');
     203    if (s == NULL) {
     204        s = path;
     205    } else {
     206        s++;
     207    }
     208    length = snprintf(message, MSG_LEN, "pymolproxy (%d) %s: %s:%d ",
     209                      getpid(), syslogLevels[priority],  s, lineNum);
     210    length += vsnprintf(message + length, MSG_LEN - length, fmt, lst);
     211    message[MSG_LEN] = '\0';
     212    if (debug) {
     213        fprintf(stderr, "%s\n", message);
     214    } else {
     215        syslog(priority, message, length);
     216    }
     217}
    175218
    176219static void PollForEvents(PymolProxy *proxyPtr);
    177220static void
    178 trace TCL_VARARGS_DEF(const char *, arg1)
     221Debug TCL_VARARGS_DEF(const char *, arg1)
    179222{
    180223    if (debug) {
     
    225268
    226269#if READTRACE
    227     trace("Entering FillBuffer (mark=%d, fill=%d)\n", readPtr->mark,
     270    Debug("Entering FillBuffer (mark=%d, fill=%d)\n", readPtr->mark,
    228271          readPtr->fill);
    229272#endif
     
    248291        if (errno != EAGAIN) {
    249292#if READTRACE
    250             trace("in FillBuffer: read failed %d: %s", errno, strerror(errno));
    251             trace("Leaving FillBuffer FAIL(read %d bytes) mark=%d, fill=%d\n",
     293            Debug("in FillBuffer: read failed %d: %s", errno, strerror(errno));
     294            Debug("Leaving FillBuffer FAIL(read %d bytes) mark=%d, fill=%d\n",
    252295                  nRead, readPtr->mark, readPtr->fill);
    253296#endif
     
    258301    readPtr->fill += nRead;
    259302#if READTRACE
    260     trace("Leaving FillBuffer (read %d bytes) mark=%d, fill=%d\n",
     303    Debug("Leaving FillBuffer (read %d bytes) mark=%d, fill=%d\n",
    261304          nRead, readPtr->mark, readPtr->fill);
    262305#endif
     
    271314
    272315#if READTRACE
    273     trace("Entering GetLine (mark=%d, fill=%d)\n",readPtr->mark, readPtr->fill);
     316    Debug("Entering GetLine (mark=%d, fill=%d)\n",readPtr->mark, readPtr->fill);
    274317#endif
    275318    status = BUFFER_OK;
     
    277320        /* Look for the next newline (the next full line). */
    278321#if READTRACE
    279         trace("in GetLine: mark=%d fill=%d\n", readPtr->mark, readPtr->fill);
     322        Debug("in GetLine: mark=%d fill=%d\n", readPtr->mark, readPtr->fill);
    280323#endif
    281324        for (i = readPtr->mark; i < readPtr->fill; i++) {
     
    289332                readPtr->mark = i;
    290333#if READTRACE
    291                 trace("Leaving GetLine(%.*s)\n", *nBytesPtr, p);
     334                Debug("Leaving GetLine(%.*s)\n", *nBytesPtr, p);
    292335#endif
    293336                return p;
     
    306349    }
    307350#if READTRACE
    308     trace("Leaving GetLine failed to read line\n");
     351    Debug("Leaving GetLine failed to read line\n");
    309352#endif
    310353    *nBytesPtr = BUFFER_CONTINUE;
     
    316359{
    317360#if READTRACE
    318     trace("Entering GetBytes(%d)\n", nBytes);
     361    Debug("Entering GetBytes(%d)\n", nBytes);
    319362#endif
    320363    while (nBytes > 0) {
     
    335378            /* Received requested # bytes. */
    336379#if READTRACE
    337             trace("Leaving GetBytes(%d)\n", nBytes);
     380            Debug("Leaving GetBytes(%d)\n", nBytes);
    338381#endif
    339382            return BUFFER_OK;
     
    345388        }
    346389#if READTRACE
    347         trace("in GetBytes: mark=%d fill=%d\n", readPtr->mark, readPtr->fill);
     390        Debug("in GetBytes: mark=%d fill=%d\n", readPtr->mark, readPtr->fill);
    348391#endif
    349392    }
    350393#if READTRACE
    351     trace("Leaving GetBytes(%d)\n", nBytes);
     394    Debug("Leaving GetBytes(%d)\n", nBytes);
    352395#endif
    353396    return BUFFER_OK;
     
    381424    sprintf(cmd, "/bin/rm -rf /tmp/pymol%d", getpid());
    382425    if (system(cmd) < 0) {
    383         trace("can't delete tmp directory: %s\n", strerror(errno));
     426        ERROR("can't delete tmp directory: %s\n", strerror(errno));
    384427    }
    385428}
     
    395438    }
    396439#if EXPECTTRACE
    397     trace("Entering Expect(want=\"%s\", maxSize=%d)\n", match, maxSize);
     440    Debug("Entering Expect(want=\"%s\", maxSize=%d)\n", match, maxSize);
    398441#endif
    399442    c = match[0];
     
    406449        if (line != NULL) {
    407450#if EXPECTTRACE
    408             trace("pymol says (read %d bytes):%.*s", nBytes, nBytes, line);
     451            Debug("pymol says (read %d bytes):%.*s", nBytes, nBytes, line);
    409452#endif
    410453            if ((c == line[0]) && (strncmp(line, match, length) == 0)) {
     
    415458                clear_error(proxyPtr);
    416459#if EXPECTTRACE
    417                 trace("Leaving Expect: got (%.*s)\n", nBytes, out);
     460                Debug("Leaving Expect: got (%.*s)\n", nBytes, out);
    418461#endif
    419462                return BUFFER_OK;
     
    425468        }
    426469    }
    427     trace("Leaving Expect: failed to find (%s)\n", match);
     470    ERROR("Leaving Expect: failed to find (%s)\n", match);
    428471    proxyPtr->error = 2;
    429472    proxyPtr->status = TCL_ERROR;
     
    561604    start = CVT2SECS(tv);
    562605
    563     trace("command from client is (%s)", cmd);
     606    Debug("command from client is (%s)", cmd);
    564607    result = Tcl_Eval(interp, cmd);
    565608
     
    579622    imgPtr = malloc(sizeof(Image) + dataLength);
    580623    if (imgPtr == NULL) {
    581         fprintf(stderr, "can't allocate image of %lu bytes",
    582                 (unsigned long)(sizeof(Image) + dataLength));
     624        ERROR("can't allocate image of %lu bytes",
     625              (unsigned long)(sizeof(Image) + dataLength));
    583626        abort();
    584627    }
     
    610653
    611654    if (proxyPtr->tailPtr == NULL) {
    612         trace("Should not be here: no image available to write");
     655        ERROR("Should not be here: no image available to write");
    613656        return;
    614657    }
     
    619662        prevPtr = imgPtr->prevPtr;
    620663#if WRITETRACE
    621         trace("WriteImage: want to write %d bytes.", imgPtr->bytesLeft);
     664        Debug("WriteImage: want to write %d bytes.", imgPtr->bytesLeft);
    622665#endif
    623666        for (bytesLeft = imgPtr->bytesLeft; bytesLeft > 0; /*empty*/) {
    624667            ssize_t nWritten;
    625668#if WRITETRACE
    626             trace("WriteImage: try to write %d bytes.", bytesLeft);
     669            Debug("WriteImage: try to write %d bytes.", bytesLeft);
    627670#endif
    628671            nWritten = write(fd, imgPtr->data + imgPtr->nWritten, bytesLeft);
    629672#if WRITETRACE
    630             trace("WriteImage: wrote %d bytes.", nWritten);
     673            Debug("WriteImage: wrote %d bytes.", nWritten);
    631674#endif
    632675            if (nWritten < 0) {
    633                 trace("Error writing fd(%d), %d/%s.", fd, errno,
     676                ERROR("Error writing fd(%d), %d/%s.", fd, errno,
    634677                      strerror(errno));
    635678                return;
     
    673716    va_end(ap);
    674717   
    675     trace("to-pymol>(%s) code=%d", buffer, result);
     718    Debug("to-pymol>(%s) code=%d", buffer, result);
    676719    script("%s\n", buffer);
    677720   
     
    681724    nWritten = write(proxyPtr->sin, buffer, length);
    682725    if (nWritten != length) {
    683         trace("short write to pymol (wrote=%d, should have been %d)",
     726        ERROR("short write to pymol (wrote=%d, should have been %d)",
    684727              nWritten, length);
    685728    }
     
    694737    result = Expect(proxyPtr, expect, buffer, BUFSIZ);
    695738    if (result == BUFFER_ERROR) {
    696         trace("timeout reading data (buffer=%s)", buffer);
     739        ERROR("timeout reading data (buffer=%s)", buffer);
    697740        proxyPtr->error = 1;
    698741        proxyPtr->status = TCL_ERROR;
     
    806849    Pymol(proxyPtr, "bmp -\n");
    807850    if (Expect(proxyPtr, "bmp image follows: ", buffer, BUFSIZ) != BUFFER_OK) {
    808         trace("can't find image follows line (%s)", buffer);
     851        ERROR("can't find image follows line (%s)", buffer);
    809852    }
    810853    if (sscanf(buffer, "bmp image follows: %d\n", &nBytes) != 1) {
     
    820863    strcpy(imgPtr->data, buffer);
    821864    if (GetBytes(&proxyPtr->server, imgPtr->data + length, nBytes)!=BUFFER_OK){
    822         trace("can't read %d bytes for \"image follows\" buffer", nBytes);
     865        ERROR("can't read %d bytes for \"image follows\" buffer", nBytes);
    823866        return  TCL_ERROR;
    824867    }
     
    13001343    strcpy(imgPtr->data, buffer);
    13011344    if (GetBytes(&proxyPtr->server, imgPtr->data + length, nBytes)!=BUFFER_OK){
    1302         trace("can't read %d bytes for \"image follows\" buffer", nBytes);
     1345        ERROR("can't read %d bytes for \"image follows\" buffer", nBytes);
    13031346        return  TCL_ERROR;
    13041347    }
     
    13591402    sprintf(buffer, "nv>image %d print \"%s\" %d\n", nBytes, token,
    13601403            proxyPtr->rockOffset);
    1361     trace("header is png is (%s)\n", buffer);
     1404    Debug("header is png is (%s)\n", buffer);
    13621405    length = strlen(buffer);
    13631406    imgPtr = NewImage(proxyPtr, nBytes + length);
    13641407    strcpy(imgPtr->data, buffer);
    13651408    if (GetBytes(&proxyPtr->server, imgPtr->data + length, nBytes)!=BUFFER_OK){
    1366         trace("can't read %d bytes for \"image follows\" buffer", nBytes);
     1409        ERROR("can't read %d bytes for \"image follows\" buffer", nBytes);
    13671410        return  TCL_ERROR;
    13681411    }
     
    19291972    child = fork();
    19301973    if (child < 0) {
    1931         fprintf(stderr, "can't fork process: %s\n", strerror(errno));
     1974        ERROR("can't fork process: %s\n", strerror(errno));
    19321975        return -3;
    19331976    }
     
    19561999       
    19572000        execvp(argv[0], argv);
    1958         trace("Failed to start pymol `%s'", argv[0]);
     2001        ERROR("Failed to start pymol `%s'", argv[0]);
    19592002        exit(-1);
    19602003    }
    19612004    stats.child = child;
    19622005
    1963     trace("Started %s DISPLAY=%s\n", argv[0], getenv("DISPLAY"));
     2006    Debug("Started %s DISPLAY=%s\n", argv[0], getenv("DISPLAY"));
    19642007
    19652008    /* close opposite end of pipe, these now belong to the child process  */
     
    19822025    interp = Tcl_CreateInterp();
    19832026    if (CreateTmpDir(interp) != TCL_OK) {
    1984         trace(Tcl_GetStringResult(interp));
     2027        ERROR(Tcl_GetStringResult(interp));
    19852028    }
    19862029    Tcl_MakeSafe(interp);
     
    20162059    stats.start = end;
    20172060
    2018     write(cout, "pymol   ", 8);
     2061    if (write(cout, "PyMol 1.0\n", 10) != 10) {
     2062        ERROR("short write of signature");
     2063    }
    20192064   
    20202065    // Main Proxy Loop
     
    20322077    status = waitpid(child, &result, WNOHANG);
    20332078    if (status == -1) {
    2034         trace("error waiting on pymol server to exit: %s", strerror(errno));
     2079        ERROR("error waiting on pymol server to exit: %s", strerror(errno));
    20352080    } else if (status == 0) {
    2036         trace("attempting to signal (SIGTERM) pymol server.");
     2081        ERROR("attempting to signal (SIGTERM) pymol server.");
    20372082        kill(-child, SIGTERM);          // Kill process group
    20382083        alarm(5);
     
    20412086       
    20422087        while ((status == -1) && (errno == EINTR)) {
    2043             trace("Attempting to signal (SIGKILL) pymol server.");
     2088            ERROR("Attempting to signal (SIGKILL) pymol server.");
    20442089            kill(-child, SIGKILL);      // Kill process group
    20452090            alarm(10);
     
    20492094    }
    20502095   
    2051     trace("pymol server process ended (result=%d)", result);
     2096    ERROR("pymol server process ended (result=%d)", result);
    20522097    DestroyTmpDir();
    20532098
     
    20942139        nChannels = poll(pollResults, nChannels, timeout);
    20952140        if (nChannels < 0) {
    2096             trace("POLL ERROR: %s", strerror(errno));
     2141            ERROR("POLL ERROR: %s", strerror(errno));
    20972142            continue;           /* or exit? */
    20982143        }
     
    21072152            char *line;
    21082153           
    2109             trace("Reading pymol stdout\n");
     2154            Debug("Reading pymol stdout\n");
    21102155            /* Don't care what's in the server output buffer. */
    21112156            FlushBuffer(&proxyPtr->server);
    21122157            line = GetLine(&proxyPtr->server, &nBytes);
    21132158            if (line != NULL) {
    2114                 trace("STDOUT>%.*s", nBytes, line);
    2115                 trace("Done with pymol stdout\n");
     2159                Debug("STDOUT>%.*s", nBytes, line);
     2160                Debug("Done with pymol stdout\n");
    21162161            } else if (nBytes == BUFFER_CONTINUE) {
    2117                 trace("Done with pymol stdout\n");
     2162                Debug("Done with pymol stdout\n");
    21182163            } else {
    2119                 trace("Failed reading pymol stdout (nBytes=%d)\n", nBytes);
     2164                ERROR("Failed reading pymol stdout (nBytes=%d)\n", nBytes);
    21202165                goto error;     /* Get out on EOF or error. */
    21212166            }
     
    21262171            char buf[BUFSIZ];
    21272172           
    2128             trace("Reading pymol stderr\n");
     2173            Debug("Reading pymol stderr\n");
    21292174            /* pyMol Stderr Connection: pymol standard error output */
    21302175           
    21312176            nRead = read(pollResults[2].fd, buf, BUFSIZ-1);
    21322177            if (nRead <= 0) {
    2133                 trace("unexpected read error from server (stderr): %s",
     2178                ERROR("unexpected read error from server (stderr): %s",
    21342179                      strerror(errno));
    21352180                if (errno != EINTR) {
    2136                     trace("lost connection (stderr) to pymol server.");
     2181                    ERROR("lost connection (stderr) to pymol server.");
    21372182                    return;
    21382183                }
    21392184            }
    21402185            buf[nRead] = '\0';
    2141             trace("stderr>%s", buf);
    2142             trace("Done reading pymol stderr\n");
     2186            Debug("stderr>%s", buf);
     2187            Debug("Done reading pymol stderr\n");
    21432188        }
    21442189
    21452190        /* We have some descriptors ready. */
    21462191        if (pollResults[0].revents & POLLIN) {
    2147             trace("Reading client stdout\n");
     2192            Debug("Reading client stdout\n");
    21482193            for (;;) {
    21492194                int nBytes;
     
    21662211                    break;
    21672212                }
    2168                 trace("Failed reading client stdout (nBytes=%d)\n", nBytes);
     2213                ERROR("Failed reading client stdout (nBytes=%d)\n", nBytes);
    21692214                goto error;             /* Get out on EOF or error. */
    21702215            }
    2171             trace("done with client stdout\n");
     2216            Debug("done with client stdout\n");
    21722217        }
    21732218        /*
  • trunk/packages/vizservers/vtkvis/RpVtkRenderServer.cpp

    r2372 r2381  
    172172     * also be used to supply information about the server (version, memory
    173173     * size, etc). */
    174     write(g_fdOut, "vtkvis  ", 8);
     174    fprintf(stdout, "VtkVis 1.0\n");
     175    fflush(stdout);
    175176
    176177    g_renderer = new Renderer();
Note: See TracChangeset for help on using the changeset viewer.