33 void showFile(
const char *fn,
int show,
int keep);
44 if (withctx) printf(
" \n");
45 printf(
" NB: The PQ2 tools are deprecated and not maintained any longer and will be removed in ROOT v6.16/00\n");
46 printf(
" Please contact the ROOT team in the unlikely event this change is disruptive for your workflow.\n");
47 if (withctx) printf(
" \n");
52 int main(
int argc,
char **argv)
56 if (argc > 1 && !strcmp(argv[1],
"-h")) {
58 printf(
" PQ2 functionality\n");
62 printf(
" $ ./pq2 [-h] [-v] [-k] <action> [-d datasetname|datasetfile] [-s server] -u serviceurl\n");
64 printf(
" Arguments:\n");
65 printf(
" -h prints this menu\n");
66 printf(
" -v verbose mode\n");
67 printf(
" -k keep temporary files\n");
68 printf(
" <action> ls, ls-files, ls-files-server, info-server, put, rm, verify\n");
69 printf(
" datasetname Name of the dataset; the wild card '*' is accepted: in \n");
70 printf(
" such a case the full path - as shown by pq2-ls - must \n");
71 printf(
" be given in quotes, e.g. \"/default/ganis/h1-set5*\"\n");
72 printf(
" (applies to: ls-files, ls-files-server, rm, verify\n");
73 printf(
" datasetfile Path to the file with the list of files in the dataset or \n");
74 printf(
" directory with the files containing the file lists of the \n");
75 printf(
" datasets to be registered; in the first case wildcards '*' \n");
76 printf(
" can be specified in the file name, i.e. \"<dir>/fil*\" is ok \n");
77 printf(
" but \"<dir>/*/file\" is not. In all cases the name of the \n");
78 printf(
" dataset is the name of the file finally used\n");
79 printf(
" (applies to: put)\n");
80 printf(
" server Name of the server for which the information is wanted; can be in \n");
81 printf(
" URL form \n");
82 printf(
" (applies to: ls-files-server, info-server)\n");
83 printf(
" serviceurl entry point of the service to be used to get the information (PROOF master\n");
84 printf(
" or data server) in the form '[user@]host.domain[:port]'\n");
94 const char *action = 0;
96 const char *dataset = 0;
97 const char *servers = 0;
98 const char *options = 0;
99 const char *ignsrvs = 0;
100 const char *excsrvs = 0;
102 const char *fout = 0;
103 const char *plot = 0;
104 const char *infile = 0;
105 const char *outfile = 0;
106 const char *redir = 0;
109 if (!strcmp(argv[i],
"-h")) {
112 }
else if (!strcmp(argv[i],
"-d")) {
113 if (i+1 == argc || argv[i+1][0] ==
'-') {
114 Printf(
" -d should be followed by a string: ignoring");
120 }
else if (!strcmp(argv[i],
"-o")) {
121 if (i+1 == argc || argv[i+1][0] ==
'-') {
122 Printf(
" -o should be followed by a string: ignoring");
128 }
else if (!strcmp(argv[i],
"-e") ||!strcmp(argv[i],
"--exclude") ) {
129 if (i+1 == argc || argv[i+1][0] ==
'-') {
130 Printf(
" -e or --exclude should be followed by a string: ignoring");
136 }
else if (!strcmp(argv[i],
"-i") ||!strcmp(argv[i],
"--ignore") ) {
137 if (i+1 == argc || argv[i+1][0] ==
'-') {
138 Printf(
" -i or --ignore should be followed by a string: ignoring");
144 }
else if (!strcmp(argv[i],
"-s") || !strcmp(argv[i],
"--servers")) {
145 if (i+1 == argc || argv[i+1][0] ==
'-') {
146 Printf(
" -s or --servers should be followed by a string: ignoring");
152 }
else if (!strcmp(argv[i],
"-m")) {
153 if (i+1 == argc || argv[i+1][0] ==
'-') {
154 Printf(
" -m should be followed by a string: ignoring");
160 }
else if (!strcmp(argv[i],
"-f")) {
161 if (i+1 == argc || argv[i+1][0] ==
'-') {
162 Printf(
" -f should be followed by a string: ignoring");
168 }
else if (!strcmp(argv[i],
"-r")) {
169 if (i+1 == argc || argv[i+1][0] ==
'-') {
170 Printf(
" -r should be followed by a string: ignoring");
176 }
else if (!strcmp(argv[i],
"-u")) {
177 if (i+1 == argc || argv[i+1][0] ==
'-') {
178 Printf(
" -u should be followed by a string: ignoring");
184 }
else if (!strcmp(argv[i],
"--plot")) {
185 if (i+1 == argc || argv[i+1][0] ==
'-') {
192 }
else if (!strcmp(argv[i],
"--infile")) {
193 if (i+1 == argc || argv[i+1][0] ==
'-') {
194 Printf(
" --infile should be followed by a string: ignoring");
200 }
else if (!strcmp(argv[i],
"--outfile")) {
201 if (i+1 == argc || argv[i+1][0] ==
'-') {
202 Printf(
" --outfile should be followed by a string: ignoring");
208 }
else if (!strncmp(argv[i],
"-v",2)) {
210 if (!strncmp(argv[i],
"-vv", 3))
gverbose++;
211 if (!strncmp(argv[i],
"-vvv", 4))
gverbose++;
213 }
else if (!strncmp(argv[i],
"-k",2)) {
222 Printf(
"Specifying an action is mandatory - exit");
229 const char *actions[nact] = {
"ls",
"ls-files",
"ls-files-server",
230 "info-server",
"put",
"rm",
"verify",
231 "ana-dist",
"cache" };
232 const char *tags[nact] = {
"ls",
"lsfiles",
"filessrv",
233 "infosrv",
"put",
"rm",
"vfy",
"anadist",
"cache" };
236 for (i = 0; i < nact; i++) {
237 if (action && !strcmp(action, actions[i])) {
243 Printf(
"Unknown action: %d (%s)", iact, action ? action :
"");
252 if (!(tdir.EndsWith(ug->fUser))) {
253 if (!(tdir.EndsWith(
"/"))) tdir +=
"/";
259 Printf(
"Could create temp directory at: %s", tdir.Data());
262 flog.
Form(
"%s/pq2%s.log", tdir.Data(), tag);
263 ferr.
Form(
"%s/pq2%s.err", tdir.Data(), tag);
264 fres.
Form(
"%s/pq2%s.res", tdir.Data(), tag);
273 TString dsmgracts = getenv(
"PQ2DSSRVACTS") ? getenv(
"PQ2DSSRVACTS")
274 :
"ls:lsfiles:filessrv:infosrv:anadist:cache:" ;
277 if (dsmgracts.
Contains(atag) && getenv(
"PQ2DSSRVURL")) {
278 url = getenv(
"PQ2DSSRVURL");
279 }
else if (getenv(
"PROOFURL") || getenv(
"PQ2PROOFURL")) {
280 url = getenv(
"PQ2PROOFURL") ? getenv(
"PQ2PROOFURL") : getenv(
"PROOFURL");
283 Printf(
"Specifying a service URL is mandatory - exit");
287 if (
gverbose > 0)
Printf(
"Checking URL: %s", url ? url :
"--undef--");
290 Printf(
"Specified URL does not identifies a running service: %s", url);
298 do_ls(dataset, options);
300 }
else if (iact == 1) {
304 }
else if (iact == 2) {
308 }
else if (iact == 3) {
312 }
else if (iact == 4) {
316 }
else if (iact == 5) {
320 }
else if (iact == 6) {
324 }
else if (iact == 7) {
326 do_anadist(dataset, servers, ignsrvs, excsrvs, metrics, fout, plot, outfile, infile);
328 }
else if (iact == 8) {
330 bool clear = (options && !strcmp(options,
"clear")) ? 1 : 0;
335 Printf(
"Unknown action code: %d - Protocol error?", iact);
338 catch (std::exception&
exp) {
339 Printf(
"Standard exception caught: '%s' - We exit whatever it is ...", exp.what());
342 catch (
const char *str) {
343 Printf(
"Exception thrown: %s", str);
347 Printf(
"Handle uncaugth exception, terminating");
357 Printf(
"Temporary files kept: ");
373 if (fn && strlen(fn)) {
376 Printf(
"File '%s' cannot be stated or is not regular: ignoring", fn);
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
void do_anadist(const char *ds, const char *servers, const char *ignsrvs, const char *excsrvs, const char *metrics, const char *fnout, const char *plot, const char *outfile, const char *infile)
Execute 'analyze-distribution' for the dataset(s) described by 'ds'.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Class supporting a collection of lines with C++ code.
void do_rm(const char *dsname)
Execute 'rm'.
Bool_t R_ISREG(Int_t mode)
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual void Print(Option_t *option="") const
Print contents of this macro.
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
R__EXTERN TSystem * gSystem
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
void do_info_server(const char *server)
Execute 'info-server'.
void do_cache(bool clear, const char *ds)
Execute 'cache'.
int main(int argc, char **argv)
int do_verify(const char *dsname, const char *opt, const char *redir)
Execute 'verify'.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Int_t checkUrl(const char *url, const char *flog, bool def_proof)
Check if something is running at gUrl Return 0 if OK and data server 1 if OK and PROOF server -1 if n...
void PrintDeprecation(bool withctx=true)
void showFile(const char *fn, int show, int keep)
Display the content of file 'fn'.
virtual Int_t GetUid(const char *user=0)
Returns the user's id. If user = 0, returns current user's id.
void do_put(const char *files, const char *opt)
Execute 'put'.
virtual void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
void do_ls(const char *ds, const char *opt)
Execute 'ls'.
void do_ls_files_server(const char *ds, const char *server)
Execute 'ls-files'.
const char * Data() const