[Oval-commits] r193 - in trunk/oval-server: . OvalServer

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


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

Modified:
   trunk/oval-server/OvalServer.BUGS
   trunk/oval-server/OvalServer.TODO
   trunk/oval-server/OvalServer/OvalHttpServer.py
   trunk/oval-server/oval-server.py
Log:
Add proper handling of missing log dirs

Modified: trunk/oval-server/OvalServer/OvalHttpServer.py
===================================================================
--- trunk/oval-server/OvalServer/OvalHttpServer.py	2007-08-23 09:58:27 UTC (rev 192)
+++ trunk/oval-server/OvalServer/OvalHttpServer.py	2007-08-23 11:22:00 UTC (rev 193)
@@ -47,6 +47,8 @@
 			except IOError:
 				self.send_error(404, 'File Not Found: %s.xml' % agentIP)
 		else:
+			self.send_response(204)
+			self.end_headers()
 			db.addAgent(agentIP)
 			agentID = db.getAgentInfo(agentIP)
 			self.server.logger.debug('httpThread: Agent %s - sync definitions' % agentIP)
@@ -54,7 +56,6 @@
 			data = conv.createDefList(files)
 			conv.saveOvalDef('%s/%s.xml' % (self.server.workdir, agentIP))
 			self.server.logger.debug('httpThread: Agent %s - definitions synced' % agentIP)
-			#TODO: Make proper respond
 			
 class HttpsRequestHandler (HttpRequestHandler):
 	"""http request handler with QUIT stopping the server"""

Modified: trunk/oval-server/OvalServer.BUGS
===================================================================
--- trunk/oval-server/OvalServer.BUGS	2007-08-23 09:58:27 UTC (rev 192)
+++ trunk/oval-server/OvalServer.BUGS	2007-08-23 11:22:00 UTC (rev 193)
@@ -1,5 +1,3 @@
 CTRL+C don't kill server
-Logging don't create directories
-Create definitions for agent without sync
 Fix UTC/Local time in timestamps
      
\ No newline at end of file

Modified: trunk/oval-server/OvalServer.TODO
===================================================================
--- trunk/oval-server/OvalServer.TODO	2007-08-23 09:58:27 UTC (rev 192)
+++ trunk/oval-server/OvalServer.TODO	2007-08-23 11:22:00 UTC (rev 193)
@@ -11,9 +11,6 @@
 	Implement mail sync
 	Implement rss sync
 Filtering by release
-Add createDefinitions hook on new agent registration and do_POST
 
 proper license headers in all code files, I don't see any of them with that
-the server/agent should either warn about the cfg directories missing or should create them
-the http code over at STDOUT in both agent/server is quite ugly
-and, of course, the debug level should be settable (either config or command line)
\ No newline at end of file
+the server/agent should either warn about the cfg directories missing or should create them
\ No newline at end of file

Modified: trunk/oval-server/oval-server.py
===================================================================
--- trunk/oval-server/oval-server.py	2007-08-23 09:58:27 UTC (rev 192)
+++ trunk/oval-server/oval-server.py	2007-08-23 11:22:00 UTC (rev 193)
@@ -3,6 +3,7 @@
 from dsa2oval import convertor
 from dba.dba import dba
 import os, logging, sys, time, getopt
+import traceback, exceptions
 
 class OvalServerNotSupported(Exception):
 	pass
@@ -107,12 +108,13 @@
 	def __init__(self, cfgfile):
 		try:
 			# Read global server config
-			self.config.read(cfgfile)
+			if not self.config.read(cfgfile):
+				raise configNotFoundError, 'Config file %s not found.\n' % cfgfile 
+
 			self.dsa_storage = self.config.get('general', 'dsa_storage')
 			self.db = self.config.get('general', 'db')
-			#Init static field in dba class
+			#Init static fields in dba and Dsa2Oval classes
 			dba.dbPath = self.db
-			#Init static field in Dsa2Oval class
 			convertor.Dsa2Oval.inputDir = self.dsa_storage
 			
 			logdirname = self.config.get('general', 'log_dir')
@@ -136,11 +138,10 @@
 			self.logger.info('Logging begins')
 		
 		except IOError, e:
-			self.logger.exception('error: %s', str(e))
+			sys.stderr.write("Can't create logger handler: " + str(e))
 			logging.shutdown()
-			exit()
+			sys.exit(2)
 
-
 	def readConfigSection (self, section):
 		conf = {}
 		
@@ -196,7 +197,7 @@
 		usage(sys.argv[0])
 		sys.exit(0)
 	
-	#Crate agent instance and run it
+	#Crate server instance and run it
 	try:
 		main = mainThread(opts['-c'])
 		main.run ()
@@ -204,6 +205,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)))
+		sys.stderr.write('Unhandled error during execution: %s : %s.\n' % (e.__class__, str(e)))
 		traceback.print_exc()
\ No newline at end of file




More information about the Oval-commits mailing list