summaryrefslogtreecommitdiffstats
path: root/libs/parser/parser.py
diff options
context:
space:
mode:
authorShwetha-H-Panduranga <shwetha@gluster.com>2011-12-12 11:29:47 +0530
committerShwetha-H-Panduranga <shwetha@gluster.com>2011-12-12 11:29:47 +0530
commit689f862f24f949361603a808250ae3f7ec9f40f6 (patch)
tree37894a4807f9fcf1edab4ad846e57d8ba339cf13 /libs/parser/parser.py
parentd7524954807ed63ed05762a945e7e6956c929eda (diff)
Changes to logger class, Using the logger class in the framework, adding new global values, Changes made to argument parser, testruninfo
Diffstat (limited to 'libs/parser/parser.py')
-rw-r--r--libs/parser/parser.py52
1 files changed, 16 insertions, 36 deletions
diff --git a/libs/parser/parser.py b/libs/parser/parser.py
index ee3a2d1..70619c9 100644
--- a/libs/parser/parser.py
+++ b/libs/parser/parser.py
@@ -24,11 +24,13 @@ def verify_necessary_options(cp, section, necessary_options):
Success: True (if all necessary_options are found in 'section')
Failure: False ( if any of the necessaty_options not found in 'section')
"""
+ logger = GlobalObj.getLoggerObj()
all_options_found = True
items = dict(cp.items(section))
for option in necessary_options:
if not (items.has_key(option) and items[option]):
- print "' %s ' Should be defined in Section: %s" % (option, section)
+ logger.error("' %s ' Should be defined in Section: %s" %
+ (option, section))
all_options_found = False
return all_options_found
@@ -40,14 +42,13 @@ def parse_testrun_info_file(filename):
GlobalObj.initTestrunInfoObj()
testruninfo_obj = GlobalObj.getTestrunInfoObj()
cp = ConfigParser.SafeConfigParser()
- necessary_sections = ["keywords", "testunits", "atfdir",
- "summarylog","detaillog", "stdoutlog",
- "glusterversion"]
+ necessary_sections = ["keywords", "testunits", "glusterversion"]
matched_sections = []
unmatched_sections = []
+ logger = GlobalObj.getLoggerObj()
if not cp.read(filename):
- print "Error reading file ' %s '.File Not found " % filename
+ logger.error("Error reading file ' %s '.File Not found " % filename)
return 1
else:
available_sections = cp.sections()
@@ -63,8 +64,8 @@ def parse_testrun_info_file(filename):
if not found_all_sections:
for section in unmatched_sections:
- print "Section %s Not Found" % section
- print "Please define the above sections in TestRunInfo File"
+ logger.error("Section %s Not Found" % section)
+ logger.error("Please define the above sections in TestRunInfo File")
return 1
else:
@@ -81,37 +82,12 @@ def parse_testrun_info_file(filename):
if testunit:
testruninfo_obj.addTestUnits(testunit)
- elif re.match("atfdir", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- atfdir = Map['dir']
- if not atfdir:
- print "dir option not defined in ATFDir. " + \
- "The 'dir'option should be defined"
- return 1
- else:
- testruninfo_obj.addAtfDir(atfdir)
-
- elif re.match("summarylog", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- testruninfo_obj.addSummaryLogInfo(Map['filename'],
- Map['loglevel'])
-
- elif re.match("detaillog", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- testruninfo_obj.addDetailLogInfo(Map['filename'],
- Map['loglevel'])
-
- elif re.match("stdoutlog", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- testruninfo_obj.addStdoutLogInfo(Map['do_log'],
- Map['loglevel'])
-
elif re.match("glusterversion", section, re.IGNORECASE):
Map = dict(cp.items(section))
glusterversion = Map['version']
if not glusterversion:
- print "version option not defined in GlusterVersion. " + \
- "The 'version' option should be defined"
+ logger.error("version option not defined in GlusterVersion. " + \
+ "The 'version' option should be defined")
return 1
else:
testruninfo_obj.addGlusterVersion(glusterversion)
@@ -124,8 +100,10 @@ def parse_testcaseslist_file(filename):
"""
return_status = 1
testcaseslist = []
+ logger = GlobalObj.getLoggerObj()
+
if not os.path.exists(filename):
- print "%s file not found." % filename
+ logger.error("%s file not found." % filename)
return return_status
testruninfo_obj = GlobalObj.getTestrunInfoObj()
@@ -190,8 +168,10 @@ def parse_testenv_configfile(filename):
"mount" : "addMount",
"defaults" : "addDefaults"}
section_pattern = re.compile('(export|server|brick|volume|client|mountdevice|mount)*')
+ logger = GlobalObj.getLoggerObj()
+
if not cp.read(filename):
- print "Error reading file ' %s '.File Not found " % filename
+ logger.error("Error reading file ' %s '.File Not found " % filename)
return 1
else:
defaults = dict(cp.defaults())