[Oval-commits] r286 - trunk/oval-server

Pavel Vinogradov blaze-guest at alioth.debian.org
Tue Oct 30 17:29:44 UTC 2007


Author: blaze-guest
Date: 2007-10-30 17:29:44 +0000 (Tue, 30 Oct 2007)
New Revision: 286

Modified:
   trunk/oval-server/oval-server.py
Log:
Update serverThread comments

Modified: trunk/oval-server/oval-server.py
===================================================================
--- trunk/oval-server/oval-server.py	2007-10-30 17:27:54 UTC (rev 285)
+++ trunk/oval-server/oval-server.py	2007-10-30 17:29:44 UTC (rev 286)
@@ -4,6 +4,8 @@
 # Written by Pavel Vinogradov <Pavel.Vinogradov at nixdev.net>
 # Licensed under the GNU General Public License version 2.
 
+"""Start OVAL server programm."""
+
 from ConfigParser import SafeConfigParser
 from threading import Thread
 import os, logging, sys, time, getopt
@@ -12,6 +14,8 @@
 from oval.dsa2oval import convertor
 from oval.dba.dba import dba
 
+assert sys.version_info >= (2,4), 'Requires Python 2.4 or better'
+
 class OvalServerNotSupported(Exception):
 	pass
 
@@ -19,6 +23,7 @@
 	pass
 
 logLevels = {'CRITICAL' : 50, 'ERROR' : 40, 'WARNING' : 30, 'INFO' : 20, 'DEBUG' : 10, 'NOTSET' : 0}
+threadStatus = {'INACTIVE' : 10, 'RUN' : 20, 'WORK' : 30, 'STOP' : 40}
 
 def usage (prog = 'oval-server.py'):
 	"""Print information about script flags and options"""
@@ -28,12 +33,23 @@
 \t-c\tpath to config file (by default /etc/oval/server.conf""" % prog
 
 
-class httpThread(Thread):	
-	""" HttpServer thread. 
+class serverThread(Thread):	
+	""" serverThread - thread which handle cleant requests to server. 
 
-	    Server requests from clients
+	    Server requests from clients, particular server type depends
+	    on configuration file, but currently inplement only OvalHttpServer.
 	"""
+
 	def __init__ (self, config, logger):
+		""" Init class variables and create apropriate server instance
+		
+		Use config variable as SafeConfigParser instance to extract 
+		apropriate config values.
+		
+		Create apropriate server instance to handle clients request
+		(currently support only http server).
+		"""
+
 		Thread.__init__(self)
 		self.setName("httpThread")
 		self.type = config['type']
@@ -50,10 +66,21 @@
 		else:
 			raise OvalServerNotSupported()
 		
-	def run (self):		
+	def run (self):
+		""" Activate request handling 
+
+		Run handling of client request in loop until stop()
+		will called.
+		
+		For http server - don't interrupted during accept() call.
+		"""
 		self.server.serve_forever()
 		
 	def stop (self):
+		""" Stop request handling
+
+		Set server execution status to False that interrupt
+		request handling loop"""
 		self.server.stop()
 		
 class syncThread(Thread):
@@ -198,7 +225,8 @@
 				
 		self.logger.info('Shutting down')
 		logging.shutdown()		
-		
+
+
 if __name__ == "__main__":
 	#Parse command line options. 
 	#By default we search for config file in global etc directory 




More information about the Oval-commits mailing list