commit-gnue
[Top][All Lists]
Advanced

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

gnue/reports/src GRReportInfo.py GRRun.py GRRun...


From: Jason Cater
Subject: gnue/reports/src GRReportInfo.py GRRun.py GRRun...
Date: Mon, 04 Nov 2002 19:48:01 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/11/04 19:48:01

Modified files:
        reports/src    : GRReportInfo.py GRRun.py 
Added files:
        reports/src    : GRRunUI.py 

Log message:
        reports can now use the wx login, if --ui wx is passed; also --batch 
command line works

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/GRRunUI.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/GRReportInfo.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/GRRun.py.diff?tr1=1.18&tr2=1.19&r1=text&r2=text

Patches:
Index: gnue/reports/src/GRReportInfo.py
diff -c gnue/reports/src/GRReportInfo.py:1.1 
gnue/reports/src/GRReportInfo.py:1.2
*** gnue/reports/src/GRReportInfo.py:1.1        Mon Nov  4 16:13:19 2002
--- gnue/reports/src/GRReportInfo.py    Mon Nov  4 19:48:00 2002
***************
*** 70,77 ****
  
      return params
  
-   def getNamespace(self):
  
      layout = None
      for child in self.report._children:
        if child._type == "GRLayout":
--- 70,77 ----
  
      return params
  
  
+   def getNamespace(self):
      layout = None
      for child in self.report._children:
        if child._type == "GRLayout":
Index: gnue/reports/src/GRRun.py
diff -c gnue/reports/src/GRRun.py:1.18 gnue/reports/src/GRRun.py:1.19
*** gnue/reports/src/GRRun.py:1.18      Mon Nov  4 16:13:19 2002
--- gnue/reports/src/GRRun.py   Mon Nov  4 19:48:00 2002
***************
*** 34,39 ****
--- 34,40 ----
  from GREngine import GREngine
  import GRFilters
  import GRExceptions
+ from GRRunUI import GRRunUI
  from GRReportInfo import GRReportInfo
  import string, sys
  import tempfile
***************
*** 87,93 ****
            'List the available [predefined] filters available to GNUe 
Reports'],
        [ 'filter_options', 'F', 'filter-options', 1, '', 'opts',
            'Options to pass to the filter process. Available options are '
!           'specific to the filter.  --filter-list will list available filters 
'
            'and their options.  Example: \'--filter-options "paper=letter 
margin=1,1,1,1" \''],
        [ 'sortoption', 's', 'sort', 1, '', 'sort',
            'Select the "sort-option" used to sort the report. '],
--- 88,94 ----
            'List the available [predefined] filters available to GNUe 
Reports'],
        [ 'filter_options', 'F', 'filter-options', 1, '', 'opts',
            'Options to pass to the filter process. Available options are '
!           'specific to the filter.  --list-filters will list available 
filters '
            'and their options.  Example: \'--filter-options "paper=letter 
margin=1,1,1,1" \''],
        [ 'sortoption', 's', 'sort', 1, '', 'sort',
            'Select the "sort-option" used to sort the report. '],
***************
*** 99,104 ****
--- 100,107 ----
            'Run GNUe Reports in quiet mode -- i.e., display no output. '
            'NOTE: if --debug-level is specified, then suppressed text will '
            'be output as debugging information (at debug level 1)'],
+       [ 'ui', 'U', 'ui', 1, 'text', 'interface',
+           'Run GNUe Reports using a specific UI.  Possible UI\'s are text and 
gui.'],
        [ 'comment', 'C', 'comment', 0, 0, None,
            'Include structural comments in the XML output stream. '
            'Useful for debugging .grd files.'],
***************
*** 130,146 ****
    #
    def __init__(self):
      GClientApp.__init__(self, application='reports',defaults=ConfigOptions)
-     lh = LoginHandler()
- 
-     try:
-       if len(self.OPTIONS['user']):
-         lh.defaults['_username'] = self.OPTIONS['user']
-       if len(self.OPTIONS['password']):
-         lh.defaults['_password'] = self.OPTIONS['password']
-     except:
-       pass
- 
-     self.getConnectionManager().setLoginHandler(lh)
  
  
    def run(self):
--- 133,138 ----
***************
*** 188,193 ****
--- 180,191 ----
        sortoption = None
  
  
+     filter = self.OPTIONS['filter']
+     destination = self.OPTIONS["destination"]
+     destinationType = self.OPTIONS["destination_type"]
+     destinationOptions = self.OPTIONS["destination_options"]
+ 
+ 
      #
      # Set quiet mode
      #
***************
*** 199,204 ****
--- 197,241 ----
  
  
      #
+     # 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
+                       )
+ 
+       lh = runui.getLoginHandler()
+       self.getConnectionManager().setLoginHandler(lh)
+ 
+       runui.run()
+ 
+       userParameters = runui.getParameters()
+       destination = runui.getDestination()
+       destinationType = runui.getDestinationType()
+       filter = runui.getFilter()
+       sortoption = runui.getSortOption()
+ 
+     else:
+       lh = NoLoginHandler()
+       self.getConnectionManager().setLoginHandler(lh)
+ 
+     try:
+       if len(self.OPTIONS['user']):
+         lh.defaults['_username'] = self.OPTIONS['user']
+       if len(self.OPTIONS['password']):
+         lh.defaults['_password'] = self.OPTIONS['password']
+     except:
+       pass
+ 
+ 
+ 
+ 
+     #
      # Now, run an engine instance
      #
      # TODO: Once reports is server-ized, this call
***************
*** 209,218 ****
      #
      try:
        GREngine(self.getConnectionManager()).processReport(reportfile,
!           destination = self.OPTIONS["destination"],
!           destinationType = self.OPTIONS["destination_type"],
!           destinationOptions = self.OPTIONS["destination_options"],
!           filter = self.OPTIONS['filter'],
            batch = self.OPTIONS['batch'],
            filterOptions = self.OPTIONS['filter_options'],
            parameters=userParameters,
--- 246,255 ----
      #
      try:
        GREngine(self.getConnectionManager()).processReport(reportfile,
!           destination = destination,
!           destinationType = destinationType,
!           destinationOptions = destinationOptions,
!           filter = filter,
            batch = self.OPTIONS['batch'],
            filterOptions = self.OPTIONS['filter_options'],
            parameters=userParameters,
***************
*** 230,237 ****
    #
    def listFilters(self, location):
  
-     # TODO: um, implement??
- 
      self.printVersion()
  
      reportInfo = self.getReportInformation(location)
--- 267,272 ----
***************
*** 274,326 ****
      return GRReportInfo(location)
  
  
  #
! # This is a (temporary?) solution to getting a login
  #
  from gnue.common import GLoginHandler
! 
! try:
!   import getpass
! except:
!   getpass = None
! 
! class LoginHandler(GLoginHandler.LoginHandler):
  
    defaults = {'_username': None, '_password': None}
  
    def getLogin(self, loginData, error):
!     try:
!       quietprint ( "*"*60 )
!       if len(loginData[1]):
!         quietprint ( 'Attempting to log into "%s" (%s):' % (loginData[1], 
loginData[0]) )
!       else:
!         quietprint ( 'Attempting to log into %s:' % (loginData[0]) )
!       quietprint ("")
!       val = {}
!       for prompt in loginData[2]:
!          if self.defaults.has_key(prompt[0])  and self.defaults[prompt[0]]:
!            quietprint_nl ( "  %s: " % prompt[1] )
!            if prompt[2]:
!              quietprint ( "***" )
!            else:
!              quietprint ( self.defaults[prompt[0]] )
!            val[prompt[0]] = self.defaults[prompt[0]]
!          else:
!            if prompt[2] and getpass:
!              val[prompt[0]] = getpass.getpass("  %s: " % prompt[1])
!            else:
!              val[prompt[0]] = raw_input("  %s: " % prompt[1])
!       quietprint ("")
!       quietprint ("*"*60)
!       return val
!     except KeyboardInterrupt:
!       raise GLoginHandler.UserCanceledLogin
! 
  
    def destroyLoginDialog(self):
      pass
  
  if __name__ == '__main__':
    GRRun().run()
- 
  
--- 309,335 ----
      return GRReportInfo(location)
  
  
+ 
  #
! # Login handler for --batch mode
  #
  from gnue.common import GLoginHandler
! class NoLoginHandler(GLoginHandler.LoginHandler):
  
    defaults = {'_username': None, '_password': None}
  
    def getLogin(self, loginData, error):
!     val = {}
!     for prompt in loginData[2]:
!        if self.defaults.has_key(prompt[0])  and self.defaults[prompt[0]]:
!          val[prompt[0]] = self.defaults[prompt[0]]
!        else:
!          val[prompt[0]] = None
!     return val
  
    def destroyLoginDialog(self):
      pass
  
  if __name__ == '__main__':
    GRRun().run()
  




reply via email to

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