Changeset 4680 for trunk/MagicSoft/Mars/macros/sql
- Timestamp:
- 08/18/04 11:21:29 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/macros/sql
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/macros/sql/filldotrbk.C
r4601 r4680 40 40 // "/data/MAGIC/Period019/ccdata" would do it for one Period 41 41 // "/data/MAGIC/Period019/ccdata/2004_05_17" would do it for a single day 42 // "/data/MAGIC/Period019/ccdata/file.rbk" would do it for a single file 42 43 // 43 44 // The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is … … 54 55 // 55 56 // Make sure, that database and password are corretly set in the macro. 57 // 58 // Returns 0 in case of failure and 1 in case of success. 56 59 // 57 60 /////////////////////////////////////////////////////////////////////////// … … 102 105 // insert the entries from this runbook file into the database 103 106 // 104 voidinsert(MSQLServer &serv, Bool_t dummy, TString fname)107 int insert(MSQLServer &serv, Bool_t dummy, TString fname) 105 108 { 106 109 //cout << endl; … … 111 114 { 112 115 cout << "Could not open file " << fname << endl; 113 return ;116 return 0; 114 117 } 115 118 … … 190 193 TSQLResult *res = serv.Query(query); 191 194 if (!res) 195 { 192 196 cout << "ERROR: " << query << endl << endl; 193 else194 {195 delete res; 196 num++;197 }197 return 0; 198 } 199 200 delete res; 201 num++; 198 202 199 203 entry = ""; … … 202 206 cout << fname(TRegexp("CC_.*.rbk", kFALSE)) << " <" << num << ">"; 203 207 cout << (dummy?" DUMMY":"") << endl; 208 209 return 1; 204 210 } 205 211 … … 208 214 // loop over all files in this path 209 215 // 210 voidfilldotrbk(TString path="/data/MAGIC/Period017/ccdata", Bool_t dummy=kTRUE)216 int filldotrbk(TString path="/data/MAGIC/Period017/ccdata", Bool_t dummy=kTRUE) 211 217 { 212 218 MSQLServer serv("mysql://hercules:d99swMT!@localhost"); … … 214 220 { 215 221 cout << "ERROR - Connection to database failed." << endl; 216 return ;222 return 0; 217 223 } 218 224 … … 225 231 cout << endl; 226 232 233 if (path.EndWith(".rbk")) 234 return insert(serv, dummy, path); 235 227 236 MDirIter Next(path, "CC_*.rbk", -1); 228 237 while (1) … … 232 241 break; 233 242 234 insert(serv, dummy, name); 235 } 243 if (!insert(serv, dummy, name)) 244 return 0; 245 } 246 247 return 1; 236 248 } -
trunk/MagicSoft/Mars/macros/sql/filldotrun.C
r4601 r4680 47 47 // "/data/MAGIC/Period019/ccdata" would do it for one Period 48 48 // "/data/MAGIC/Period019/ccdata/2004_05_17" would do it for a single day 49 // "/data/MAGIC/Period019/ccdata/file.run" would do it for a single file 49 50 // 50 51 // The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is … … 63 64 // root -q -l -b filldotrun.C+\(\"path\"\,kFALSE\) 2>&1 | tee filldotrun.log 64 65 // 66 // Returns 0 in case of failure and 1 in case of success. 67 // 65 68 ///////////////////////////////////////////////////////////////////////////// 66 69 #include <iostream> … … 152 155 { 153 156 ifstream fin(filename); 157 if (!fin) 158 { 159 cout << "Could not open file " << fname << endl; 160 return -1; 161 } 154 162 155 163 TString strng; … … 160 168 cout << "First Line: " << strng << endl; 161 169 cout << endl; 162 return 0;170 return -1; 163 171 } 164 172 … … 175 183 cout << "Second Line: " << strng << endl; 176 184 cout << endl; 177 return 0;185 return -1; 178 186 } 179 187 … … 387 395 { 388 396 cout << query << " - FAILED!" << endl; 389 continue;397 return -1; 390 398 } 391 399 … … 413 421 cout << endl; 414 422 423 if (path.EndsWith(".run")) 424 { 425 cout << name(TRegexp("CC_.*.run", kFALSE)) << flush; 426 Int_t n = insert(serv, dummy, name); 427 cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl; 428 429 return n<0 ? 0 : 1; 430 } 431 415 432 MDirIter Next(path, "CC_*.run", -1); 416 433 while (1) … … 421 438 422 439 cout << name(TRegexp("CC_.*.run", kFALSE)) << flush; 423 424 440 Int_t n = insert(serv, dummy, name); 425 426 441 cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl; 427 } 442 443 if (n<0) 444 return 0; 445 } 446 447 return 1; 428 448 }
Note:
See TracChangeset
for help on using the changeset viewer.