commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

r6568 - in trunk: gnue-navigator/src gnue-reports/src/client


From: johannes
Subject: r6568 - in trunk: gnue-navigator/src gnue-reports/src/client
Date: Tue, 26 Oct 2004 09:29:11 -0500 (CDT)

Author: johannes
Date: 2004-10-26 09:29:09 -0500 (Tue, 26 Oct 2004)
New Revision: 6568

Modified:
   trunk/gnue-navigator/src/GNClient.py
   trunk/gnue-navigator/src/GNObjects.py
   trunk/gnue-navigator/src/UIgtk2.py
   trunk/gnue-reports/src/client/GRRun.py
   trunk/gnue-reports/src/client/GRRunUI.py
Log:
Use RunUI in navigator (this is *not* fully functional yet)


Modified: trunk/gnue-navigator/src/GNClient.py
===================================================================
--- trunk/gnue-navigator/src/GNClient.py        2004-10-26 11:47:56 UTC (rev 
6567)
+++ trunk/gnue-navigator/src/GNClient.py        2004-10-26 14:29:09 UTC (rev 
6568)
@@ -175,6 +175,11 @@
     try:
       nav = loadProcesses (fileHandle)
 
+      # add some information to the top object
+      nav._connections   = self.connections
+      nav._configManager = self.configurationManager
+      nav._ui_type       = self.ui_type
+
     finally:
       fileHandle.close ()
 
@@ -198,10 +203,6 @@
     else:
       self.disableSplash = self.OPTIONS ['splash_screen']
 
-
-    # add connections object to top object
-    nav._connections = self.connections
-    
     self._ui.Instance (nav).run (self.connections)
 
 

Modified: trunk/gnue-navigator/src/GNObjects.py
===================================================================
--- trunk/gnue-navigator/src/GNObjects.py       2004-10-26 11:47:56 UTC (rev 
6567)
+++ trunk/gnue-navigator/src/GNObjects.py       2004-10-26 14:29:09 UTC (rev 
6568)
@@ -33,115 +33,207 @@
 from gnue import paths
 import GNParser
 try:
-  from gnue.reports.base import GREngine,GRExceptions
-  REPORTS_SUPPORT=1
+  from gnue.reports.base import GREngine
+  from gnue.reports.base import GRExceptions
+  from gnue.reports.base import GRReportInfo
+  from gnue.reports.client import GRRunUI
+
+  REPORTS_SUPPORT = True
+
 except ImportError:
-  REPORTS_SUPPORT=0
+  REPORTS_SUPPORT = False
 
+# =============================================================================
 # Base class for all Navigator objects
-class GNObject(GObjects.GObj):
+# =============================================================================
+
+class GNObject (GObjects.GObj):
   pass
 
 
-class GNProcesses(GRootObj.GRootObj, GNObject):
+# =============================================================================
+# This class implements the root objects of a process tree
+# =============================================================================
 
-  def __init__(self, parent=None):
-    GRootObj.GRootObj.__init__(self,'processes',GNParser.getXMLelements, 
GNParser)
-    GNObject.__init__(self, parent, type="GNProcesses")
-    self._clientHandlers = {
-      'form': self._runForm,
-      'report': self._runReport,
-      'app': self._runApp,
-    }
+class GNProcesses (GRootObj.GRootObj, GNObject):
 
-  def setClientHandlers(self, handlers):
-    self._clientHandlers.update(handlers)
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
 
-  def _runForm(self, step, parameters={}):
-    formCommand = gConfigNav('RunFormCommand')
+  def __init__ (self, parent = None):
 
-    if os.path.basename(step.location) == step.location:
+    GRootObj.GRootObj.__init__ (self, 'processes', GNParser.getXMLelements,
+                                GNParser)
+    GNObject.__init__ (self, parent, type = "GNProcesses")
+    self._clientHandlers = {'form'  : self._runForm,
+                            'report': self._runReport,
+                            'app'   : self._runApp}
+
+  # ---------------------------------------------------------------------------
+  # update the dictionary of client handlers
+  # ---------------------------------------------------------------------------
+
+  def setClientHandlers (self, handlers):
+    """
+    This function updates the dictionary of client handlers
+
+    @param handlers: dictionary with key as handler type and a function pointer
+        as value.
+    """
+
+    self._clientHandlers.update (handlers)
+
+
+  # ---------------------------------------------------------------------------
+  # Resolve the location of a step
+  # ---------------------------------------------------------------------------
+
+  def __resolveLocation (self, step, cfgDir):
+    """
+    This function resolves the location of a step using a base directory as
+    defined by the configuration file. If the location of a step has no
+    directory part it get's extended by the directory given by the config.
+
+    @param step: GNStep instance
+    @param cfgDir: section to take the default directory from.
+
+    @return: location to use for the step
+    """
+
+    if os.path.basename (step.location) == step.location:
       try:
-        formdir = gConfigNav('FormDir')
+        stepdir = gConfigNav (cfgDir)
+
       except KeyError:
-        formdir = ""
-      formfile = os.path.join (paths.data, formdir, step.location)
+        stepdir = ""
+
+      result = os.path.join (paths.data, stepdir, step.location)
+
     else:
-      formfile = step.location
+      result = step.location
 
+    return result
+
+
+  # ---------------------------------------------------------------------------
+  # Basic client handler for forms
+  # ---------------------------------------------------------------------------
+
+  def _runForm (self, step, parameters = {}):
+    """
+    """
+
+    formCommand = gConfigNav ('RunFormCommand')
+    formfile    = self.__resolveLocation (step, 'FormDir')
+
     if sys.platform != 'win32':
-      GDebug.printMesg(1,'Running command " %s %s"'%(formCommand,formfile))
-      os.spawnlpe(os.P_NOWAIT,formCommand,formCommand,formfile,os.environ)
+      gDebug (1, 'Running command " %s %s"' % (formCommand, formfile))
+      os.spawnlpe (os.P_NOWAIT, formCommand, formCommand, formfile, os.environ)
+
     else:
-      command = string.split("%s"%(formCommand))
-      command.append('"%s"' % formfile)
+      command = string.split ("%s" % (formCommand))
+      command.append ('"%s"' % formfile)
 
-      GDebug.printMesg(1,'Running command " %s "'%(command))
-      os.spawnve(os.P_NOWAIT,command[0],command,os.environ)
+      gDebug (1, 'Running command " %s "' % (command))
+      os.spawnve (os.P_NOWAIT, command [0], command, os.environ)
 
-  def _runApp(self, step, parameters={}):
 
-    GDebug.printMesg(1,'Running app "%s"'%(step.location))
+  # ---------------------------------------------------------------------------
+  # Basic client handler for apps
+  # ---------------------------------------------------------------------------
 
-    command = string.split(step.location)
+  def _runApp (self, step, parameters = {}):
+    """
+    """
 
+    gDebug (1, 'Running app "%s"' % (step.location))
+
+    command = string.split (step.location)
+
     if sys.platform != 'win32':
-      os.spawnvpe(os.P_NOWAIT,command[0],command,os.environ)
+      os.spawnvpe (os.P_NOWAIT, command [0], command, os.environ)
     else:
       # TODO: Not tested
-      os.spawnve(os.P_NOWAIT,command[0],command,os.environ)
+      os.spawnve (os.P_NOWAIT, command [0], command, os.environ)
 
-  def _runReport(self, step, parameters={}):
+
+  # ---------------------------------------------------------------------------
+  # Basic client handler for reports
+  # ---------------------------------------------------------------------------
+
+  def _runReport (self, step, parameters = {}):
+    """
+    """
+
     global REPORTS_SUPPORT
+
     if not REPORTS_SUPPORT:
       print "WARNING: Reports support not installed!"
       return
 
-    reportCommand = gConfigNav('RunReportCommand')
+    reportfile = self.__resolveLocation (step, 'ReportDir')
+    reportInfo = GRReportInfo.GRReportInfo (reportfile)
 
-    # get the name of the report
-    if os.path.basename(step.location) == step.location:
-      try:
-        reportdir = gConfigNav('ReportDir')
-      except KeyError:
-        reportdir = ""
-      reportfile = os.path.join (paths.data, reportdir, step.location)
-    else:
-      reportfile = step.location
-
     # default parameter should be loaded from GREngine itself
-    params ={
-      'destination_type':'file',
-      'destination':'-',
-      'destination_options':'',
-      'filter':'raw',
-      'list_filters':0,
-      'filter_options': '',
-      'sortoption':'',
-      'comment':None,
-      'exclude_xml':None }
+    params = {
+      'destination_type'   : 'file',
+      'destination'        : '-',
+      'destination_options': '',
+      'filter'             : 'raw',
+      'list_filters'       : 0,
+      'filter_options'     : '',
+      'sortoption'         : '',
+      'comment'            : None,
+      'exclude_xml'        : None}
 
-    i = self
-    while i._parent!=None:
-      i=i._parent
+    # If a step defines one of the standard parameters take it over and remove
+    # it from the step's private parameter dictionary
+    for key in params.keys ():
+      if step._params.has_key (key):
+        params [key] = step._params [key]
+        del step._params [key]
 
+    topObject = self.findParentOfType (None)
+
+    runUI = GRRunUI.GRRunUI (reportInfo,
+                             topObject._configManager,
+                             topObject._connections,
+                             topObject._ui_type,
+                             step._params,
+                             params ['destination'],
+                             params ['destination_type'],
+                             params ['filter'],
+                             params ['sortoption'])
+    runUI.run ()
+
+    params ['destination']      = runUI.getDestination ()
+    params ['destination_type'] = runUI.getDestinationType ()
+    params ['filter']           = runUI.getFilter ()
+    params ['sortoption']       = runUI.getSortOption ()
+    userParameters              = runUI.getParameters ()
+
     try:
-      engine=GREngine.GREngine(i._connections)
-      engine.processReport(reportfile,
+      engine = GREngine.GREngine (topObject._connections)
+      engine.processReport (reportfile,
                            destination = params["destination"],
                            destinationType = params["destination_type"],
                            destinationOptions = params["destination_options"],
                            filter = params['filter'],
                            filterOptions = params['filter_options'],
-                           parameters = step._params,
+                           parameters = userParameters,
                            sortoption=params["sortoption"],
                            includeStructuralComments=params["comment"],
                            omitGNUeXML=params["exclude_xml"])
+
     except GRExceptions.ReportMarkupException, msg:
       self.handleStartupError (msg)
     except GRExceptions.ReportUnreadable, msg:
       self.handleStartupError (msg)
 
+
+
+
   def handleStartupError(self,errortext):
     print
     print '-' * 60

Modified: trunk/gnue-navigator/src/UIgtk2.py
===================================================================
--- trunk/gnue-navigator/src/UIgtk2.py  2004-10-26 11:47:56 UTC (rev 6567)
+++ trunk/gnue-navigator/src/UIgtk2.py  2004-10-26 14:29:09 UTC (rev 6568)
@@ -680,6 +680,10 @@
 
     try:
       processes = GNParser.loadProcesses (fhd)
+      processes._connections   = self.processes._connections
+      processes._configManager = self.processes._configManager
+      processes._ui_type       = self.processes._ui_type
+
       newModel  = self.__buildTreeModel (processes)
       self.processes = processes
       self.__treeStore = newModel

Modified: trunk/gnue-reports/src/client/GRRun.py
===================================================================
--- trunk/gnue-reports/src/client/GRRun.py      2004-10-26 11:47:56 UTC (rev 
6567)
+++ trunk/gnue-reports/src/client/GRRun.py      2004-10-26 14:29:09 UTC (rev 
6568)
@@ -199,25 +199,26 @@
     # Will we do a UI engine
     #
     if not self.OPTIONS['batch']:
-      runui = GRRunUI(self,reportInfo=self.getReportInformation(reportfile),
-                      ui = self.OPTIONS['ui'],
-                      userParameters=userParameters,
-                      destination=destination,
-                      destinationType=destinationType,
-                      filter=filter,
-                      sortoption=sortoption
-                      )
+      runui = GRRunUI (self.getReportInformation (reportfile),
+                       self.configurationManager,
+                       self.connections,
+                       self.OPTIONS ['ui'],
+                       userParameters,
+                       destination,
+                       destinationType,
+                       filter,
+                       sortoption)
 
-      lh = runui.getLoginHandler()
-      self.getConnectionManager().setLoginHandler(lh)
+      lh = runui.getLoginHandler ()
+      self.getConnectionManager ().setLoginHandler (lh)
 
-      runui.run()
+      runui.run ()
 
-      userParameters = runui.getParameters()
-      destination = runui.getDestination()
-      destinationType = runui.getDestinationType()
-      filter = runui.getFilter()
-      sortoption = runui.getSortOption()
+      userParameters  = runui.getParameters ()
+      destination     = runui.getDestination ()
+      destinationType = runui.getDestinationType ()
+      filter          = runui.getFilter ()
+      sortoption      = runui.getSortOption ()
 
     else:
       lh = NoLoginHandler()

Modified: trunk/gnue-reports/src/client/GRRunUI.py
===================================================================
--- trunk/gnue-reports/src/client/GRRunUI.py    2004-10-26 11:47:56 UTC (rev 
6567)
+++ trunk/gnue-reports/src/client/GRRunUI.py    2004-10-26 14:29:09 UTC (rev 
6568)
@@ -43,11 +43,12 @@
   # Constructor
   # --------------------------------------------------------------------------
 
-  def __init__ (self, client, reportInfo, ui = 'text', userParameters = {},
-      destination = '-', destinationType = 'file', filter = 'raw',
-      sortoption = None):
+  def __init__ (self, reportInfo, cfgManager, connections, ui = 'text',
+      userParameters = {}, destination = '-', destinationType = 'file',
+      filter = 'raw', sortoption = None):
 
-    self.client = client
+    self.configurationManager = cfgManager
+    self.connections          = connections
 
     if ui != 'text':
       try:
@@ -55,9 +56,9 @@
 
         # Nasty hackery
         from gnue.forms.GFConfig import ConfigOptions as FormConfigOptions
-        client.configurationManager.loadApplicationConfig (section = "forms",
+        cfgManager.loadApplicationConfig (section = "forms",
                                                   defaults = FormConfigOptions)
-        client.configurationManager.registerAlias ('gConfigForms', 'forms')
+        cfgManager.registerAlias ('gConfigForms', 'forms')
 
         self.gfinstance = dyn_import ('gnue.forms.GFInstance')
 
@@ -97,7 +98,7 @@
 
       # Create the form's code on the fly and put it into an instance
       formBuffer = self.__buildForm ()
-      instance   = self.gfinstance.GFInstance (self, self.client.connections,
+      instance   = self.gfinstance.GFInstance (self, self.connections,
                                       self.uimodule, True, self.userParameters)
       instance.addFormFromFilehandle (formBuffer)
       instance.addDialogs ()
@@ -198,7 +199,8 @@
 
     code = ['<?xml version="1.0" encoding="utf-8"?>']
     code.extend (self._getXMLTag ('form', \
-        {'title': self.reportInfo.getTitle ()}, "", True))
+        {'title': self.reportInfo.getTitle (),
+         'style': 'form'}, "", True))
 
     fields = self.__translateParameters ()
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]