[Zope-CVS] CVS: Packages/FunctionalTests/FunctionalTests - ScenarioGenerator.py:1.2

Tres Seaver tseaver@zope.com
Fri, 23 May 2003 16:47:04 -0400


Update of /cvs-repository/Packages/FunctionalTests/FunctionalTests
In directory cvs.zope.org:/tmp/cvs-serv6631

Modified Files:
	ScenarioGenerator.py 
Log Message:


  - Add a knob for changing the expected extension of the raw request
    data files (e.g., to support using the new version of TCPWatch,
    which will log to files with '.request' as the extension).


=== Packages/FunctionalTests/FunctionalTests/ScenarioGenerator.py 1.1 => 1.2 ===
--- Packages/FunctionalTests/FunctionalTests/ScenarioGenerator.py:1.1	Thu Apr 24 17:39:51 2003
+++ Packages/FunctionalTests/FunctionalTests/ScenarioGenerator.py	Fri May 23 16:47:03 2003
@@ -54,6 +54,7 @@
     _capture_cookies    = 0
     _logfile_directory  = '/tmp'
     _logfile_prefix     = 'zft'
+    _logfile_extension  = 'out'
     _output_file        = None
     _exclude_patterns   = []
     _exclude_file       = None
@@ -69,8 +70,8 @@
         """
         sys.stderr.write( """
   %(GENERATOR_EXE)s [-?vq] \\
-                     [-l log_dir] [-f log_prefix] [-o file] \\
-                     [-x pattern] [-X file]
+                     [-l log_dir] [-f log_prefix] [-e log_extension] \\
+                     [-o file] [-x pattern] [-X file]
 
     -?, --help                      Print this help message
 
@@ -88,9 +89,12 @@
     -f, --logfile-prefix            Prefix for log file names
                                     (default '%(LOGFILE_PREFIX)s')
 
+    -e, --logfile-extension         Extension for log file names
+                                    (default '%(LOGFILE_EXTENSION)s')
+
     -o, --output-file               Write to 'file', instead of default
-                                    (%(LOGFILE_PREFIX)s.zft).  Use '-'
-                                    to write to stdout.
+                                    (%(LOGFILE_PREFIX)s.zft). 
+                                    Use '-' to write to stdout.
 
     -x, --exclude-pattern           Exclude requests which match 'pattern'
                                     (e.g., to suppress stylesheet or images).
@@ -101,6 +105,7 @@
 %(MESSAGE)s\n""" % { 'GENERATOR_EXE'        : sys.argv[0]
                    , 'LOGFILE_DIRECTORY'    : self._logfile_directory
                    , 'LOGFILE_PREFIX'       : self._logfile_prefix
+                   , 'LOGFILE_EXTENSION'    : self._logfile_extension
                    , 'MESSAGE'              : msg or ''
                    } )
         sys.exit( 1 )
@@ -111,12 +116,12 @@
         """
         verbosity = self._verbosity
         capture_cookies = self._capture_cookies
-        logfile_directory = logfile_prefix = output_file = None
-        exclude_file = portal_url = site_path = None
+        logfile_directory = logfile_prefix = logfile_extension = None
+        output_file = exclude_file = portal_url = site_path = None
 
         try:
             opts, ignored = getopt.getopt( args
-                                         , "?vqcCl:f:o:x:X:"
+                                         , "?vqcCl:f:e:o:x:X:"
                                          , [ 'help'
                                            , 'verbose'
                                            , 'quiet'
@@ -124,6 +129,7 @@
                                            , 'no-capture-cookies'
                                            , 'logfile-directory='
                                            , 'logfile-prefix='
+                                           , 'logfile-extension='
                                            , 'output-file'
                                            , 'exclude-pattern'
                                            , 'exclude-file'
@@ -155,6 +161,9 @@
             if o == '-f' or o == '--logfile-prefix':
                 logfile_prefix = v
 
+            if o == '-e' or o == '--logfile-extension':
+                logfile_extension = v
+
             if o == '-o' or o == '--output-file':
                 output_file = v
 
@@ -173,6 +182,9 @@
         if logfile_prefix is not None:
             self._logfile_prefix = logfile_prefix
 
+        if logfile_extension is not None:
+            self._logfile_extension = logfile_extension
+
         if output_file is not None:
             if output_file == '-':
                 self._output_file = sys.stdout
@@ -364,14 +376,16 @@
     def processScenario( self ):
         """
             Read all files in '_logfile_directory' whose prefix
-            matches '_logfile_prefix';  create a scenario file
-            with one section per request file, dumping to specified
-            output file.
+            matches '_logfile_prefix' and '_logfile_extension;
+            create a scenario file with one section per request file,
+            dumping to specified output file.
         """
         self._print( SCENARIO_SKELETON )
 
-        glob_pattern = '%s/%s_*.out' % ( self._logfile_directory
-                                       , self._logfile_prefix )
+        glob_pattern = '%s/%s_*.%s' % ( self._logfile_directory
+                                      , self._logfile_prefix
+                                      , self._logfile_extension
+                                      )
 
         request_num = 0
         parms = { 'saw_authentication' : 0 }