From 856f77b4601b136f816df6acca05cd0c281d1636 Mon Sep 17 00:00:00 2001 From: Joey Hagedorn Date: Wed, 22 Jun 2005 22:03:59 +0000 Subject: added command line options to specify alternate config and statistics files (Logical change 1.238) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@995 ce84e21b-d406-0410-9b95-82705330c041 --- src/sbin/StatReports.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/sbin/StatReports.py b/src/sbin/StatReports.py index 72aa57730..49fdf4b4e 100644 --- a/src/sbin/StatReports.py +++ b/src/sbin/StatReports.py @@ -221,12 +221,23 @@ def www(reportsections,delivery,deliverytype): if __name__ == '__main__': c = ConfigParser() c.read(['/etc/bcfg2.conf']) - statpath = "%s/statistics.xml" % c.get('server', 'metadata')#this needs - #to be configurable-- like options like, in case you want to read in a different file + configpath = "%s/report-configuration.xml" % c.get('server', 'metadata') + statpath = "%s/statistics.xml" % c.get('server', 'metadata') + try: + opts, args = getopt(argv[1:], "hc:s:", ["help", "config=", "stats="]) + except GetoptError,msg: + # print help information and exit: + print "%s\nUsage:\nStatReports.py [-h] [-c ] [-s ]"%(msg) + exit(2) + for o, a in opts: + if o in ("-h", "--help"): + print "Usage:\nStatReports.py [-h] [-c ] [-s ]" + exit() + if o in ("-c", "--config"): + configpath = a + if o in ("-s", "--stats"): + statpath = a - #configpath = "%s/machine-owners.xml" % c.get('server', 'metadata') - configpath = "/sandbox/hagedorn/report-configuration.xml" - '''Reads current state regarding statistics''' try: statdata = XML(open(statpath).read()) except (IOError, ExpatError): -- cgit v1.2.3-1-g7c22