commit-gnue
[Top][All Lists]
Advanced

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

gnue/gnuef client/gfclient src/GFDebug.py


From: Jason Cater
Subject: gnue/gnuef client/gfclient src/GFDebug.py
Date: Fri, 11 May 2001 14:58:09 -0700

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/05/11 14:58:09

Modified files:
        gnuef/client   : gfclient 
        gnuef/src      : GFDebug.py 

Log message:
        Modified gfclient to use the new GClientApp class.  Note the new help 
system :)  Developers should now try to start using 
gnue.common.GDebug.printMesg instead of GFDebug.printMesg. Note that 
GFDebug.printMesg now simply calls GDebug.printMesg, so code will not be 
broken.  However, GFDebug *should* be phased out.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/client/gfclient.diff?cvsroot=OldCVS&tr1=1.37&tr2=1.38&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFDebug.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gnue/gnuef/client/gfclient
diff -u gnue/gnuef/client/gfclient:1.37 gnue/gnuef/client/gfclient:1.38
--- gnue/gnuef/client/gfclient:1.37     Fri Apr 20 18:22:51 2001
+++ gnue/gnuef/client/gfclient  Fri May 11 14:58:09 2001
@@ -16,7 +16,7 @@
 #
 # Copyright (c) 2000 Free Software Foundation
 #
-# $Id: gfclient,v 1.37 2001/04/21 01:22:51 jcater Exp $
+# $Id: gfclient,v 1.38 2001/05/11 21:58:09 jcater Exp $
 #
 
 import pstats
@@ -28,30 +28,29 @@
 from gnue.forms.GFGetOpt import *
 from gnue.forms.GFForm import *
 from gnue.forms.GFController import *
-from gnue.forms.GFDebug import *
 from gnue.forms.GFParser import loadForm 
+from gnue.common import GDebug
 
-_usage = """
-Usage: %s [-h] [--help] [-d level] [--debug=level] \\
-       [-D tracefile] [--debug_file=tracefile] \\
-       [-u uiType] [--user_interface=uiType] [-v] [--version]
+from gnue.common.GClientApp import * 
 
-Supported uiTypes : gui, text (unstable), pytext
 
-Report bugs to address@hidden
-"""
+class GFClient(GClientApp, GFController):
 
-class GFClient(GFController):
+
+  VERSION = GFOptions.VERSION
+  NAME = "GNUe Forms"
+  COMMAND_OPTIONS = [ 
+      [ 'user_interface', 'u', 'user_interface', 1, 'gui', 'type',  
+          'The currently supported values for <type> are ' \
+          +'gui, text (unstable), and pytext' ] ]
+  SUMMARY = \
+     "GNUe Forms is the primary user interface to the GNU Enterprise system."
+
   def __init__(self):    
-    # Parse command line options 
-    self.CmdOpt = GFGetOpt()
-    self.CmdOpt.parseOptions(sys.argv)
-    self.ui_type = self.CmdOpt.getOption('user_interface')
-    GFOptions.DEBUG = self.CmdOpt.getOption('debug_level')
-    self.debug_file = self.CmdOpt.getOption('debug_file')
-    self.help = self.CmdOpt.getOption('help')
-    self.version = self.CmdOpt.getOption('version')
-    self.profile = self.CmdOpt.getOption('profile')
+    GClientApp.__init__(self)
+
+    self.ui_type = self.OPTIONS['user_interface']
+    self.profile = self.OPTIONS['profile']
 
     GFController.__init__(self)
 
@@ -327,7 +326,7 @@
   # charater be inserted into current entry object
   #
   def keyPress(self, event):
-    GFDebug.printMesg(10, "Keypress event %s"%event.data)
+    GDebug.printMesg(10, "Keypress event %s"%event.data)
     if (self._form._currentEntry != None):
       if not self._form._currentEntry.readonly or 
self._form._currentBlock.mode=='query':
         if self._form.keyPress(event.data):
@@ -437,30 +436,12 @@
 
   
   def run(self):    
-    if (self.debug_file != None):
-      fh = open( self.debug_file, 'w' )
-      GFDebug.catchStderr( fh )
-    else:
-      GFDebug.catchStderr( sys.__stderr__ )
-    if GFOptions.DEBUG>0:
-      print "Debug level =",GFOptions.DEBUG
             
     # assign form file from 1st free argument
     try:
-      self._formfile = self.CmdOpt.getArgument(0)
+      self._formfile = self.ARGUMENTS[0]
     except:
-      if self.help :
-        print _usage % (sys.argv[0])
-        sys.exit()
-      elif self.version :
-        print "%s v%s" % (sys.argv[0], GFOptions.VERSION)
-        sys.exit()
-      else: 
-        if sys.argv[0][-8:] != 'gfclient': 
-          self._formfile = 
GFOptions.FormDir+"/"+os.path.basename(sys.argv[0])+".gfd"
-        else:
-          print "No Forms Definition File Specified.  Use GFClient -h for more 
information."
-          sys.exit()
+      self.handleStartupError ("No Forms Definition File Specified.")
 
 
     # Initialize user interface (defaults to gui)
@@ -471,7 +452,7 @@
         ui=UIwxpython.GFUserInterface()
         
       else:
-        SetOptions.ui_type='text'
+        self.ui_type='text'
 
     if self.ui_type == 'pytext':
       from gnue.forms import UIpyncurses
@@ -550,16 +531,16 @@
     ui.mainLoop()
       
 if __name__ == '__main__':
-  GFClient = GFClient()
-  if GFClient.profile:
+  client = GFClient()
+  if client.profile:
     import profile
-    profile.run("GFClient.run()","runstats")
+    profile.run("client.run()","runstats")
     p = pstats.Stats('runstats')
 
     p.sort_stats('time').print_stats(50)
     p.sort_stats('cumulative').print_stats(50)
   else :  
-    GFClient.run()
+    client.run()
 
 
 
Index: gnue/gnuef/src/GFDebug.py
diff -u gnue/gnuef/src/GFDebug.py:1.2 gnue/gnuef/src/GFDebug.py:1.3
--- gnue/gnuef/src/GFDebug.py:1.2       Wed Apr 11 11:01:58 2001
+++ gnue/gnuef/src/GFDebug.py   Fri May 11 14:58:09 2001
@@ -19,7 +19,7 @@
 # Copyright 2000 Free Software Foundation
 #
 # FILE:
-# GFDebug.py
+# GFDebug.py 
 #
 # DESCRIPTION:
 # Intelligently handles traces and exception handling for GFForms
@@ -27,63 +27,9 @@
 # NOTES:
 
 
-from GFEvent import *
-import GFOptions
+from gnue.common import GDebug
 
-import string
-import sys
-from traceback import format_exception
-
-_fh = None
-_conttest = 0
-
-class _stderrcatcher:
-    def write(self, str):
-        global _fh, _conttest
-        for ch in str:
-            if (_conttest == 0):
-                _fh.write("DB000: ")
-                _conttest = 1
-            if ( ch != '\n'):
-                _fh.write(ch)
-            else:
-                _fh.write('\n')
-                _conttest = 0
-
-    def writelines(self, list):
-        for line in list:
-            self.write(str)
-
-def catchStderr(fh):
-    global _fh
-    _fh = fh
-    sys.stderr = _stderrcatcher()
-
-def handleException(exc_info):
-    #
-    #Not used at present
-    #
-    type, exception, traceback = exc_info
-    if (isinstance(exception, GFETrace) ):
-        printMesg( exception.level, exception.message)
-    elif (not isinstance(exception, SystemExit)):
-        strings = format_exception(type, exception, traceback)
-        text = string.join(strings, '')
-        printMesg(0, text)
-
 def printMesg(level, message):
-    global _fh
-    if ( int(level) <= int(GFOptions.DEBUG) ):
-        lines = string.split(message, '\n')
-        for line in lines:
-            _fh.write("DB%03d: %s\n"%(level, line))
+  GDebug.printMesg(level, message)
+
 
-class GFETrace(Exception):
-    #
-    #Exception class representing a debug message
-    #not yet used for anything and probably won't be :)
-    #
-    def __init__(self, level=0, message="Trace Message"):
-        Exception.__init__(self)
-        self.level = level
-        self.message = message



reply via email to

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