struct htmlPage *trackHubVersionSpecMustGet(char *specHost, char *version) /* Open the trackDbHub.html file and attach html reader. Use default version if NULL */ { char *specUrl; char buf[256]; if (version != NULL && startsWith("http", version)) specUrl = version; else { safef(buf, sizeof buf, "http://%s/goldenPath/help/trackDb/trackDbHub%s%s.html", specHost, version ? "." : "", version ? version: ""); specUrl = buf; } verbose(2, "Using spec at %s\n", specUrl); struct htmlPage *page = htmlPageGet(specUrl); if (page == NULL) errAbort("Can't open hub settings spec %s", specUrl); //TODO: apply page validator //htmlPageValidateOrAbort(page); // would like to use this, but current page doesn't validate // Would need to replace empty table (replaced by JS) with div, and assure htmlPageValidateOrAbort // is run on any page change. /* TODO: validate this is a trackDbHub spec */ /* (e.g. scan tags for the hub version, perhaps limiting to first N tags) */ return page; }
void hgTablesTest(char *url, char *logName) /* hgTablesTest - Test hgTables web page. */ { /* Get default page, and open log. */ struct htmlPage *rootPage = htmlPageGet(url); if (appendLog) logFile = mustOpen(logName, "a"); else logFile = mustOpen(logName, "w"); if (! endsWith(url, "hgTables")) warn("Warning: first argument should be a complete URL to hgTables, " "but doesn't look like one (%s)", url); htmlPageValidateOrAbort(rootPage); /* Go test what they've specified in command line. */ if (clDb != NULL) { testDb(rootPage, NULL, clDb); } else { struct htmlForm *mainForm; struct htmlFormVar *orgVar; if ((mainForm = htmlFormGet(rootPage, "mainForm")) == NULL) errAbort("Couldn't get main form"); if ((orgVar = htmlFormVarGet(mainForm, "org")) == NULL) errAbort("Couldn't get org var"); if (clOrg != NULL) testOrg(rootPage, mainForm, clOrg); else { struct slName *org; int orgIx; for (org = orgVar->values, orgIx=0; org != NULL && orgIx < clOrgs; org = org->next, ++orgIx) { testOrg(rootPage, mainForm, org->name); } } } /* Do some more complex tests on uniProt. */ testJoining(rootPage); testFilter(rootPage); testIdentifier(rootPage); /* Clean up and report. */ htmlPageFree(&rootPage); slReverse(&tablesTestList); reportSummary(tablesTestList, stdout); reportAll(tablesTestList, logFile); fprintf(logFile, "---------------------------------------------\n"); reportSummary(tablesTestList, logFile); }
char *getJsonViaHttps(char *url, char *userId, char *password) /* rsyncEdwExpDataType - Get experiment and data types from ENCODED via json.. */ { char fullUrl[1024]; safef(fullUrl, sizeof(fullUrl), "https://%s:%s@%s", userId, password, url); struct htmlPage *page = htmlPageGet(fullUrl); struct htmlStatus *st = page->status; if (st->status != 200) errAbort("Failed to get page from %s - status code: %d ", url, st->status); char *json=cloneString(page->htmlText); htmlPageFree(&page); return json; }
long hgTracksRandom(char *url) /* hgTracksRandom - Time default view for random position. */ /* The URL can include position. */ { long startTime, endTime; struct htmlPage *rootPage; startTime = clock1000(); rootPage = htmlPageGet(url); endTime = clock1000(); htmlPageValidateOrAbort(rootPage); if (rootPage->status->status != 200) errAbort("%s returned with status code %d", url, rootPage->status->status); return endTime - startTime; }
struct qaStatus *qaPageGet(char *url, struct htmlPage **retPage) /* Get info on given url, (and return page if retPage non-null). */ { struct errCatch *errCatch = errCatchNew(); struct qaStatus *qs; struct htmlPage *page = NULL; long startTime = clock1000(); if (errCatchStart(errCatch)) { page = htmlPageGet(url); htmlPageValidateOrAbort(page); } else { htmlPageFree(&page); } errCatchEnd(errCatch); qs = qaStatusOnPage(errCatch, page, startTime, retPage); errCatchFree(&errCatch); return qs; }
void hgNearTest(char *url, char *log) /* hgNearTest - Test hgNear web page. */ { struct htmlPage *rootPage = htmlPageGet(url); struct htmlForm *mainForm; struct htmlFormVar *orgVar; FILE *f = mustOpen(log, "w"); htmlPageValidateOrAbort(rootPage); htmlPageSetVar(rootPage, NULL, orderVarName, "geneDistance"); htmlPageSetVar(rootPage, NULL, countVarName, "25"); if ((mainForm = htmlFormGet(rootPage, "mainForm")) == NULL) errAbort("Couldn't get main form"); if ((orgVar = htmlFormVarGet(mainForm, "org")) == NULL) errAbort("Couldn't get org var"); if (clOrg != NULL) testOrg(rootPage, mainForm, clOrg, clDb); else { struct slName *org; for (org = orgVar->values; org != NULL; org = org->next) { testOrg(rootPage, mainForm, org->name, clDb); } } htmlPageFree(&rootPage); slReverse(&nearTestList); reportSummary(nearTestList, stdout); fprintf(f,"seed=%d\n",seed); reportAll(nearTestList, f); fprintf(f, "---------------------------------------------\n"); reportSummary(nearTestList, f); slFreeList(&nearTestList); carefulClose(&f); }