CMS 3D CMS Logo

Classes | Functions | Variables

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/Fireworks/Core/src/CmsShowSearchFiles.cc File Reference

#include <stdexcept>
#include <iostream>
#include <stdlib.h>
#include <set>
#include "TGClient.h"
#include "TGHtml.h"
#include "TGButton.h"
#include "TGMenu.h"
#include "TGLabel.h"
#include "TGTextEntry.h"
#include "TPluginManager.h"
#include "TUrl.h"
#include "TSocket.h"
#include "TSystem.h"
#include "TVirtualX.h"
#include "TPRegexp.h"
#include "Fireworks/Core/interface/CmsShowSearchFiles.h"
#include "Fireworks/Core/interface/fwLog.h"

Go to the source code of this file.

Classes

class  FWHtml

Functions

float getURLResponseTime (const char *url)
static std::string readRemote (const char *url)
static const std::string s_filePrefix ("file:")
static const std::string s_httpPrefix ("http:")
static const std::string s_rootPostfix (".root")

Variables

static const unsigned int s_columns = 3
static const char * s_noBrowserMessage []
static const char *const s_prefixes [][s_columns]
static const char * s_readError []

Function Documentation

float getURLResponseTime ( const char *  url)

Definition at line 51 of file CmsShowSearchFiles.cc.

References prof2calltree::l, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by CmsShowSearchFiles::CmsShowSearchFiles().

{
   TString com = "ping -q -c 1 -n " + TString(url) + "| tail -n 1";
   FILE* p = gSystem->OpenPipe(com, "r");
   TString l;
   l.Gets(p);
   gSystem->ClosePipe(p);

   TPMERegexp re("([\\d\\.]+)");
   if (re.Match(l))
      return  re[1].Atof();
   else
      return -1;
}
static std::string readRemote ( const char *  url) [static]

Definition at line 259 of file CmsShowSearchFiles.cc.

References MatrixRunner::msg, asciidump::s, and findQualityFiles::size.

Referenced by CmsShowSearchFiles::sendToWebBrowser().

{
   // Read (open) remote files.
   
   char *buf = 0;
   TUrl fUrl(url);
   
   TString msg = "GET ";
   msg += fUrl.GetProtocol();
   msg += "://";
   msg += fUrl.GetHost();
   msg += ":";
   msg += fUrl.GetPort();
   msg += "/";
   msg += fUrl.GetFile();
   msg += "\r\n";
   
   TString uri(url);
   if (!uri.BeginsWith("http://"))
      return std::string();
   TSocket s(fUrl.GetHost(), fUrl.GetPort());
   if (!s.IsValid())
      return std::string();
   if (s.SendRaw(msg.Data(), msg.Length()) == -1)
      return std::string();
   Int_t size = 1024*1024;
   buf = (char *)calloc(size, sizeof(char));
   if (s.RecvRaw(buf, size) == -1) {
      free(buf);
      return std::string();
   }
   std::string returnValue(buf);
   free(buf);
   return returnValue;
}
static const std::string s_filePrefix ( "file:"  ) [static]
static const std::string s_httpPrefix ( "http:"  ) [static]
static const std::string s_rootPostfix ( ".root"  ) [static]

Variable Documentation

const unsigned int s_columns = 3 [static]

Definition at line 39 of file CmsShowSearchFiles.cc.

Referenced by CmsShowSearchFiles::showPrefixes().

const char* s_noBrowserMessage[] [static]
Initial value:
 {
   "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ",
   "<HTML><HEAD><TITLE>No Browser Available</TITLE> ",
   "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ",
   "<BODY> ",
   
   
   "<b>Welcome....</b><BR>",
   "<BR>",
   "<b>You may look at examples:</b><BR>",  
   "If you are in Europe, open example data files at CERN:  ", " <a href=" , s_prefixes[0][0], ">",  s_prefixes[0][0], "</a><BR>",
   "If you are in US, open example data files at UCSD:", " <a href=" , s_prefixes[1][0], ">",  s_prefixes[1][0], "</a><BR>",
   "<BR>"
   "<b>You also may load files with Choose Prefix </b><BR>"
   "</BODY></HTML> ",
   0
}

Definition at line 71 of file CmsShowSearchFiles.cc.

Referenced by CmsShowSearchFiles::sendToWebBrowser().

const char* const s_prefixes[][s_columns] [static]
Initial value:
{ 
  {"http://fireworks.web.cern.ch/fireworks/samples-4.2/", "Pre-selected example files","t"},
  {"http://uaf-2.t2.ucsd.edu/fireworks-4.2/"            , "Pre-selected example files","t"},
  {"http://", "Web site known by you",0},
  {"file:","Local file [you must type full path name]",0},
  {"dcap://","dCache [FNAL]",0},
  {"rfio://","Castor [CERN]",0}
  
}

Definition at line 40 of file CmsShowSearchFiles.cc.

Referenced by CmsShowSearchFiles::CmsShowSearchFiles(), and CmsShowSearchFiles::showPrefixes().

const char* s_readError[] [static]
Initial value:
 {
   "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ",
   "<HTML><HEAD><TITLE>HTTP Read Error</TITLE> ",
   "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ",
   "<BODY> ",
   "<P>Unknown error while trying to get file via http</P>",
   "</BODY></HTML> ",
   0
}

Definition at line 89 of file CmsShowSearchFiles.cc.

Referenced by CmsShowSearchFiles::sendToWebBrowser().