[Oval-commits] r194 - trunk/oval-agent

Pavel Vinogradov blaze-guest at alioth.debian.org
Thu Aug 23 11:22:27 UTC 2007


Author: blaze-guest
Date: 2007-08-23 11:22:27 +0000 (Thu, 23 Aug 2007)
New Revision: 194

Modified:
   trunk/oval-agent/oval-agent.py
Log:
Add proper handling of missing log-dirs

Modified: trunk/oval-agent/oval-agent.py
===================================================================
--- trunk/oval-agent/oval-agent.py	2007-08-23 11:22:00 UTC (rev 193)
+++ trunk/oval-agent/oval-agent.py	2007-08-23 11:22:27 UTC (rev 194)
@@ -12,7 +12,7 @@
 from ConfigParser import SafeConfigParser
 import os, logging, sys
 import getopt
-import traceback
+import traceback, exceptions
 from ovalHttpClient import ovalHttpClient
 
 class configNotFoundError (Exception):
@@ -25,7 +25,7 @@
 
 	print """usage: python %s [-h] [-c <config>]
 \t-h\tthis help
-\t-d\tpath to config file (by default oval-agent.cfg""" % prog
+\t-c\tpath to config file (by default oval-agent.cfg""" % prog
 
 class agentThread:
 	config = SafeConfigParser()
@@ -54,14 +54,15 @@
 				logging.root.setLevel(logLevels[self.log_level])
 			else:
 				logging.root.setLevel(logging.WARNING)
-				self.logger.warning('Wrong value of log_level key in config.')
+				self.logger.warning('Wrong value of log_level key in config. Use WARNING as default.')
 				
 			self.logger.info('Logging begins')
 
 		except IOError, e:
-			self.logger.exception('error: ' + str(e))
+			sys.stderr.write("Can't create logger handler: " + str(e))
 			logging.shutdown()
-			exit(2)
+			sys.exit(2)
+
 			
 	def readConfigSection (self, section):
 		""" Parse section of config file into dict
@@ -121,6 +122,8 @@
 		sys.stderr.write (str(e))
 	except KeyboardInterrupt, e:
 		sys.stderr.write ('Execution interrupted by keyboard.')
+	except exceptions.SystemExit, e:
+		raise e
 	except Exception, e:
 		sys.stderr.write('Unhandled error during execution: %s : %s.' % (e.__class__, str(e)))
 		traceback.print_exc()
\ No newline at end of file




More information about the Oval-commits mailing list