Commit 0c5a40d9 authored by Giuseppe Lo Presti's avatar Giuseppe Lo Presti

Added support for "short" output

parent fefc16f8
Pipeline #311617 passed with stages
in 23 minutes 48 seconds
......@@ -39,15 +39,17 @@ import cx_Oracle
############################################################
# usage function
def usage(exitCode):
print 'Usage : ' + sys.argv[0] + ' [-h|--help] [-m] fileId|castorFileName'
print 'Usage : ' + sys.argv[0] + ' [-h|--help] [-m] [-s] fileId|castorFileName'
print 'Query NameServer and Stager databases to get the footprint of a file in CASTOR'
print ' -m print output with a key=value formatting'
print ' -s short output: print namespace and disk metadata only'
sys.exit(exitCode)
# first parse the options
shortOutput = False
printFunc = castor_tools.prettyPrintTable
try:
options, args = getopt.getopt(sys.argv[1:], 'hm', ['help'])
options, args = getopt.getopt(sys.argv[1:], 'hms', ['help'])
except Exception, e:
print e
usage(1)
......@@ -56,6 +58,8 @@ for f, v in options:
usage(0)
elif f == '-m':
printFunc = castor_tools.keyValuePrintTable
elif f == '-s':
shortOutput = True
else:
print "unknown option : " + f
usage(1)
......@@ -112,6 +116,8 @@ try:
titles = ['DISKCOPYID', 'STATUS', 'CREATIONTIME', 'POOL', 'LOCATION', 'AVAIL', 'DCSIZE', 'FILESIZE', 'GCWEIGHT']
print '\n### Stager DiskCopy information'
printFunc(titles, rows)
if shortOutput:
sys.exit(0)
print '\n### Stager DiskCopy physical status (stat + cksum)'
for f in rows:
(host, path) = f[4].split(':')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment