32 std::string option =
"-c";
33 std::string constr =
"`cmsGetFnConnect frontier://smallfiles`";
34 std::string sherpack =
"sherpa_" +
SherpaProcess +
"_MASTER.tgz";
35 std::string sherpackunzip =
"sherpa_" +
SherpaProcess +
"_MASTER.tar";
42 std::cout <<
"SherpackFetcher: Trying to fetch the Sherpack " << sherpack << std::endl;
45 std::cout <<
"SherpackFetcher: Fetching of Sherpack did not succeed, terminating" << std::endl;
48 std::cout <<
"SherpackFetcher: Fetching successful" << std::endl;
51 std::ifstream my_file(sherpack.c_str());
54 std::cout <<
"SherpackFetcher: No Sherpack found" << std::endl;
58 std::cout <<
"SherpackFetcher: Sherpack found" << std::endl;
63 for (
int k=0;
k<33;
k++){
65 std::cout <<
"SherpackFetcher: failure, calculated and specified checksums differ!" << std::endl;
69 std::cout <<
"SherpackFetcher: Calculated checksum of the Sherpack is " << md5checksum <<
" and matches" << std::endl;
71 std::cout <<
"SherpackFetcher: Ignoring Checksum" << std::endl;
75 std::cout <<
"SherpackFetcher: Trying to unzip the Sherpack" << std::endl;
78 std::cout <<
"SherpackFetcher: Decompressing failed " << std::endl;
81 std::cout <<
"SherpackFetcher: Decompressing successful " << std::endl;
83 FILE *
file = fopen(const_cast<char*>(sherpackunzip.c_str()),
"r");
85 std::cout <<
"SherpackFetcher: Decompressed Sherpack exists with name " << sherpackunzip <<
" starting to untar it"<<std::endl;
88 std::cout <<
"SherpackFetcher: Could not open decompressed Sherpack" << std::endl;
98 unsigned long channel;
116 if(frontier_init(malloc,free)!=0)
118 fprintf(stderr,
"Error initializing frontier client: %s\n",frontier_getErrorMsg());
123 config=frontierConfig_get(connectstr.c_str(),
"",&ec);
126 fprintf(stderr,
"Error getting frontierConfig object: %s\n",frontier_getErrorMsg());
129 channel=frontier_createChannel2(config,&ec);
132 fprintf(stderr,
"Error creating frontier channel: %s\n",frontier_getErrorMsg());
138 FrontierRSBlob *frsb;
142 const char *localname;
144 const char *
path=pathstring.c_str();
145 snprintf(uribuf,
sizeof(uribuf)-1,
"Frontier/type=frontier_file:1:DEFAULT&encoding=BLOB&p1=%s",path);
146 ec=frontier_getRawData(channel,uribuf);
149 fprintf(stderr,
"Error getting data for %s: %s\n",path,frontier_getErrorMsg());
152 frsb=frontierRSBlob_open(channel,0,1,&ec);
155 fprintf(stderr,
"Error opening result blob for %s: %s\n",path,frontier_getErrorMsg());
159 (void)frontierRSBlob_getByte(frsb,&ec);
162 fprintf(stderr,
"Error getting result type for %s: %s\n",path,frontier_getErrorMsg());
165 n=frontierRSBlob_getInt(frsb,&ec);
168 fprintf(stderr,
"Error getting result size for %s: %s\n",path,frontier_getErrorMsg());
171 p=frontierRSBlob_getByteArray(frsb,n,&ec);
174 fprintf(stderr,
"Error getting result data for %s: %s\n",path,frontier_getErrorMsg());
177 localname=strrchr(path,
'/');
179 localname=pathstring.c_str();
182 fd=open(localname,O_CREAT|O_TRUNC|O_WRONLY,0666);
185 fprintf(stderr,
"Error creating %s: %s\n",localname,strerror(errno));
191 fprintf(stderr,
"Error writing to %s: %s\n",localname,strerror(errno));
197 printf(
"%d bytes written to %s\n",n,localname);
198 frontierRSBlob_close(frsb,&ec);
201 frontier_closeChannel(channel);
203 return (ec==FRONTIER_OK);
T getParameter(std::string const &) const
virtual std::string explainSelf() const
void md5_File(std::string, char *)
std::string SherpackLocation
bool exists(std::string const ¶meterName) const
checks if a parameter exists
virtual std::string const lookupCalibConnect(std::string const &input) const =0
static ServiceToken createContaining(std::auto_ptr< T > iService)
create a service token that holds the service defined by iService
std::string SherpackChecksum
void Untar(FILE *, const char *)
SherpackFetcher(edm::ParameterSet const &)
int FnFileGet(std::string)
std::string SherpaProcess
int Unzip(std::string, std::string)