--- DarthVader/src/R2-D2.cpp 2006/09/06 15:20:23 1.4 +++ DarthVader/src/R2-D2.cpp 2006/09/08 08:12:28 1.7 @@ -32,9 +32,9 @@ printf("\n -v | --verbose be verbose [default: print nothing on STDOUT]\n"); printf("\n -idRun ID_RUN: ID number of the run \n"); printf("\n -filename output yoda filename \n"); - printf("\n -host name for the host [default = mysql://localhost/pamelaprod]\n"); - printf("\n -user username for the DB [default = anonymous] \n"); - printf("\n -psw password for the DB [default = \"\"]\n"); + printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); + printf("\n -user username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n"); + printf("\n -psw password for the DB [default = $PAM_DBPSW or \"\"]\n"); printf("\n -convert [ -tzone timezone -dbtime dbtime ] \n"); printf("\n convert the dbtime given in seconds (from the DB) to a string for\n"); printf("\n the given time zone (UTC,GMT,MSK,MSD,CET,CEST are accepted) \n"); @@ -63,6 +63,16 @@ TString host = "mysql://localhost/pamelaprod"; TString user = "anonymous"; TString psw = ""; + // + const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); + const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); + const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); + if ( strcmp(pamdbhost,"") ) host = pamdbhost; + if ( strcmp(pamdbuser,"") ) user = pamdbuser; + if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; + // + // printf(" host %s user %s psw %s \n",host.Data(),user.Data(),psw.Data()); + // TString tzone = "MSK"; TString tzone2 = "MSK"; TString runtime = "1970-01-01 00:00:00"; @@ -258,13 +268,13 @@ error = glrun->Query_GL_RUN(run,dbc); glroot->Clear(); error = glroot->Query_GL_ROOT(glrun->ID_ROOT_L0,dbc); - if ( error ){ - printf(" Error querying the DB! \n"); - exit(-4); - }; - if ( !glrun->ID ){ + if ( !glrun->ID_ROOT_L0 ){ printf("\n No run with ID=%u in the DB!\n",run); } else { + if ( error ){ + printf(" Error querying the DB! \n"); + exit(-4); + }; printf("\n Run %u belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data()); }; };