Ignore:
Timestamp:
08/18/04 11:21:29 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/macros/sql
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/macros/sql/filldotrbk.C

    r4601 r4680  
    4040//   "/data/MAGIC/Period019/ccdata"             would do it for one Period
    4141//   "/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
    4243//
    4344// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
     
    5455//
    5556// 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.
    5659//
    5760///////////////////////////////////////////////////////////////////////////
     
    102105// insert the entries from this runbook file into the database
    103106//
    104 void insert(MSQLServer &serv, Bool_t dummy, TString fname)
     107int insert(MSQLServer &serv, Bool_t dummy, TString fname)
    105108{
    106109    //cout << endl;
     
    111114    {
    112115        cout << "Could not open file " << fname << endl;
    113         return;
     116        return 0;
    114117    }
    115118
     
    190193        TSQLResult *res = serv.Query(query);
    191194        if (!res)
     195        {
    192196            cout << "ERROR: " << query << endl << endl;
    193         else
    194         {
    195             delete res;
    196             num++;
    197         }
     197            return 0;
     198        }
     199
     200        delete res;
     201        num++;
    198202
    199203        entry = "";
     
    202206    cout << fname(TRegexp("CC_.*.rbk", kFALSE)) << " <" << num << ">";
    203207    cout << (dummy?" DUMMY":"") << endl;
     208
     209    return 1;
    204210}
    205211
     
    208214// loop over all files in this path
    209215//
    210 void filldotrbk(TString path="/data/MAGIC/Period017/ccdata", Bool_t dummy=kTRUE)
     216int filldotrbk(TString path="/data/MAGIC/Period017/ccdata", Bool_t dummy=kTRUE)
    211217{
    212218    MSQLServer serv("mysql://hercules:d99swMT!@localhost");
     
    214220    {
    215221        cout << "ERROR - Connection to database failed." << endl;
    216         return;
     222        return 0;
    217223    }
    218224
     
    225231    cout << endl;
    226232
     233    if (path.EndWith(".rbk"))
     234        return insert(serv, dummy, path);
     235
    227236    MDirIter Next(path, "CC_*.rbk", -1);
    228237    while (1)
     
    232241            break;
    233242
    234         insert(serv, dummy, name);
    235     }
     243        if (!insert(serv, dummy, name))
     244            return 0;
     245    }
     246
     247    return 1;
    236248}
  • trunk/MagicSoft/Mars/macros/sql/filldotrun.C

    r4601 r4680  
    4747//   "/data/MAGIC/Period019/ccdata"             would do it for one Period
    4848//   "/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
    4950//
    5051// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
     
    6364//   root -q -l -b filldotrun.C+\(\"path\"\,kFALSE\) 2>&1 | tee filldotrun.log
    6465//
     66// Returns 0 in case of failure and 1 in case of success.
     67//
    6568/////////////////////////////////////////////////////////////////////////////
    6669#include <iostream>
     
    152155{
    153156    ifstream fin(filename);
     157    if (!fin)
     158    {
     159        cout << "Could not open file " << fname << endl;
     160        return -1;
     161    }
    154162
    155163    TString strng;
     
    160168        cout << "First Line: " << strng << endl;
    161169        cout << endl;
    162         return 0;
     170        return -1;
    163171    }
    164172
     
    175183        cout << "Second Line: " << strng << endl;
    176184        cout << endl;
    177         return 0;
     185        return -1;
    178186    }
    179187
     
    387395        {
    388396            cout << query << " - FAILED!" << endl;
    389             continue;
     397            return -1;
    390398        }
    391399
     
    413421    cout << endl;
    414422
     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
    415432    MDirIter Next(path, "CC_*.run", -1);
    416433    while (1)
     
    421438
    422439        cout << name(TRegexp("CC_.*.run", kFALSE)) << flush;
    423 
    424440        Int_t n = insert(serv, dummy, name);
    425 
    426441        cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl;
    427     }
     442
     443        if (n<0)
     444            return 0;
     445    }
     446
     447    return 1;
    428448}
Note: See TracChangeset for help on using the changeset viewer.