[Oval-commits] r371 - trunk/oval-monitor

Pavel Vinogradov blaze-guest at alioth.debian.org
Mon Sep 15 17:06:40 UTC 2008


Author: blaze-guest
Date: 2008-09-15 17:06:39 +0000 (Mon, 15 Sep 2008)
New Revision: 371

Modified:
   trunk/oval-monitor/manager.py
   trunk/oval-monitor/reporter.py
Log:
Remove redundant deps. SOme workd on grid.

Modified: trunk/oval-monitor/manager.py
===================================================================
--- trunk/oval-monitor/manager.py	2008-09-15 17:04:56 UTC (rev 370)
+++ trunk/oval-monitor/manager.py	2008-09-15 17:06:39 UTC (rev 371)
@@ -1,8 +1,10 @@
 import wx
+import wx.grid
 import os
+import sys
+import traceback
+from reporter import Report
 
-from db import Report
-
 ID_ABOUT=wx.NewId()
 ID_OPEN=wx.NewId()
 ID_PREFERENCES=wx.NewId()
@@ -13,8 +15,9 @@
     def __init__(self,parent,id,title):
         #self.dirname=''
         wx.Frame.__init__(self, parent, wx.ID_ANY, title, pos=(150, 150), size=(350, 200))
-        self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
-      
+        self.grid = wx.grid.Grid(self) #wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
+        self.grid.CreateGrid(5,5)
+        
         # Setting statusbar
         self.CreateStatusBar() # A Statusbar in the bottom of the window
         
@@ -54,7 +57,7 @@
         # Use some sizers to see layout options
         self.sizer=wx.BoxSizer(wx.VERTICAL)
         self.sizer.Add(self.sizer2,0,wx.EXPAND)
-        self.sizer.Add(self.control,1,wx.EXPAND)
+        self.sizer.Add(self.grid,1,wx.EXPAND)
                 
         #Layout sizers
         self.SetSizer(self.sizer)
@@ -85,21 +88,27 @@
     def OnClick(self,event):
         result = " Click on object with Id %d\n" %event.GetId() 
         try:
-            reporter = Report ("/etc/oval/server.conf")
-            result = reporter.reportFull ()
+            reporter = Report ("./oval-server.db")
+            #self.grid.CreateGrid(5,5)
+            #self.grid.SetRowHeight(4, 45)
+            self.grid.SetCellValue("First cell", 0, 0)
+            self.grid.SetCellValue("Another cell", 1, 1)
+            self.grid.SetCellValue("Yet another cell", 2, 2)
+            #grid.SetCellTextFont(wxTheFontList->FindOrCreateFont(12, wxROMAN, wxITALIC, wxNORMAL), 0, 0);
+            self.grid.SetCellTextColour(wx.wxRED, 1, 1)
+            self.grid.SetCellBackgroundColour(wx.wxCYAN, 2, 2)
+            self.grid.UpdateDimensions()
+            
+            #grid.SetCellRenderer(0,0,reporter.reportFull ())
+            #grid.SetColSize(0,img.GetWidth()+2)
+            #grid.SetRowSize(0,img.GetHeight()+2)
+            #result = reporter.reportFull ()
         
-        except configNotFoundError, e:
-            sys.stderr.write (str(e))
-        except dbaNotAccesible, e:
-            sys.stderr.write ("ERROR: Can't access to database file\n")
-            usage(sys.argv[0])
-        except exceptions.SystemExit, e:
-            raise e
         except Exception, e:
             sys.stderr.write('ERROR: Unhandled error during execution: %s : %s.\n' % (e.__class__, str(e)))
             traceback.print_exc()
         
-        self.control.AppendText(result)
+        #self.control.AppendText(result)
 
 if __name__ == "__main__":
     app = wx.PySimpleApp()

Modified: trunk/oval-monitor/reporter.py
===================================================================
--- trunk/oval-monitor/reporter.py	2008-09-15 17:04:56 UTC (rev 370)
+++ trunk/oval-monitor/reporter.py	2008-09-15 17:06:39 UTC (rev 371)
@@ -3,7 +3,6 @@
 #                                                                                                   # Written by Pavel Vinogradov
 # Licensed under the GNU General Public License version 2.
 
-from ConfigParser import SafeConfigParser
 from dba import dba, dbaNotAccesible
 import os, sys, time, getopt
 import traceback, exceptions
@@ -11,36 +10,12 @@
 
 assert sys.version_info >= (2,4), 'Requires Python 2.4 or better'
 
-class configNotFoundError (Exception):
-    pass
-
-def usage (prog = 'oval-monitor.py'):
-    """Print information about script flags and options"""
-
-    print """usage: python %s [-h] [-c <config>] [-a <agent ip>] [-d <dsa id>]
-\t-h\tthis help
-\t-c\tpath to config file (by default /etc/oval/server.conf
-\t-a\tagent id
-\t-d\tDebian Security Annnounce id
-""" % prog
-
 class Report:
-    
-    config = SafeConfigParser()
 
-    def __init__(self, cfgfile):
-        try:
-            # Read global server config
-            if not self.config.read(cfgfile):
-                raise configNotFoundError, 'Config file %s not found.\n' % cfgfile 
+    def __init__(self, dbfile):
+        dba.dbPath = dbfile
+        self.db = dba ()
 
-            self.dbPath = self.config.get ('general', 'db')
-            #Init static fields in dba and Dsa2Oval classes
-            dba.dbPath = "/tmp/oval-server.db"#self.dbPath
-            self.db = dba ()
-        except Exception, e:
-            raise e
-
     def getAgentAffectedVuln (self, agentID):
         """ Return list of affected DSA for certain agent
 
@@ -162,50 +137,4 @@
         dsas = cursor.fetchall()[0][0]
         result += 'DSA in repository: %d\n' % dsas
         
-        return result
-
-if __name__ == "__main__":
-    #Parse command line options. 
-    #By default we search for config file in global etc directory 
-    opts = {'-c' : '/etc/oval/server.conf'}
-    
-    try:
-        opt, args = getopt.getopt (sys.argv[1:], 'hc:a:d:')
-    except getopt.GetoptError:
-        usage (sys.argv[0])
-        sys.exit(1)
-    
-    for key, value in opt: 
-        opts[key] = value
-
-    if opts.has_key ('-h'):
-        usage(sys.argv[0])
-        sys.exit(0)
-
-    try:
-        reporter = Report (opts['-c'])
-    
-        if opts.has_key ('-a'):
-            try:
-                reporter.reportAgent (int(opts['-a']))
-            except ValueError:
-                print 'Please enter numeric agent ID'
-        else:
-            if opts.has_key ('-d'):
-                try:
-                    reporter.reportDSA (int(opts['-d']))
-                except ValueError:
-                    print 'Please enter numeric DSA id'
-            else:
-                reporter.reportFull ()
-    
-    except configNotFoundError, e:
-        sys.stderr.write (str(e))
-    except dbaNotAccesible, e:
-        sys.stderr.write ("ERROR: Can't access to database file\n")
-        usage(sys.argv[0])
-    except exceptions.SystemExit, e:
-        raise e
-    except Exception, e:
-        sys.stderr.write('ERROR: Unhandled error during execution: %s : %s.\n' % (e.__class__, str(e)))
-        traceback.print_exc()
\ No newline at end of file
+        return result
\ No newline at end of file




More information about the Oval-commits mailing list