[Zope-CVS] CVS: Packages/tcpwatch - CHANGES.txt:1.1 setup.py:1.3 tcpwatch.py:1.3 MANIFEST.in:NONE launch:NONE setup.cfg:NONE

Shane Hathaway shane@zope.com
Mon, 16 Jun 2003 15:06:45 -0400


Update of /cvs-repository/Packages/tcpwatch
In directory cvs.zope.org:/tmp/cvs-serv1719

Modified Files:
	setup.py tcpwatch.py 
Added Files:
	CHANGES.txt 
Removed Files:
	MANIFEST.in launch setup.cfg 
Log Message:
Minor style updates.  Also removed unneeded files.


=== Added File Packages/tcpwatch/CHANGES.txt ===

Version 1.2

  - Added the ability to record TCP sessions to a directory.
    Use -r <path>.  Implemented by Tres Seaver.

  - Replaced the launch script with a distutils setup.py, thanks again
    to Tres Seaver.



=== Packages/tcpwatch/setup.py 1.2 => 1.3 ===
--- Packages/tcpwatch/setup.py:1.2	Tue May 27 10:12:40 2003
+++ Packages/tcpwatch/setup.py	Mon Jun 16 15:06:44 2003
@@ -1,14 +1,13 @@
 #!/usr/bin/env python
 
 from distutils.core import setup
-from distutils.sysconfig import get_python_lib
 
-setup( name="tcpwatch"
-     , version="1.2"
-     , description="Connection forwarder / HTTP proxy"
-     , author="Shane Hathaway"
-     , author_email="shane@zope.com"
-     , url="http://hathaway.freezope.org/Software/TCPWatch"
-     , py_modules=[ 'tcpwatch' ]
-     , scripts=[ 'launch' ]
+setup(name="tcpwatch",
+      version="1.2",
+      description="TCP monitoring and logging tool with support for HTTP 1.1",
+      author="Shane Hathaway",
+      author_email="shane@zope.com",
+      url="http://hathaway.freezope.org/Software/TCPWatch",
+      scripts=('tcpwatch.py',),
      )
+


=== Packages/tcpwatch/tcpwatch.py 1.2 => 1.3 ===
--- Packages/tcpwatch/tcpwatch.py:1.2	Tue May 27 10:12:40 2003
+++ Packages/tcpwatch/tcpwatch.py	Mon Jun 16 15:06:44 2003
@@ -1246,10 +1246,11 @@
 #############################################################################
 
 def usage():
-    print COPYRIGHT
-    print 'Utility for monitoring TCP and HTTP connections'
-    print 'Simple usage: tcpwatch -L listen_port:dest_hostname:dest_port'
-    print """
+    sys.stderr.write(COPYRIGHT + '\n')
+    sys.stderr.write(
+        """TCP monitoring and logging tool with support for HTTP 1.1
+Simple usage: tcpwatch.py -L listen_port:dest_hostname:dest_port
+
 TCP forwarded connection setup:
   -L <listen_port>:<dest_port>
      Set up a local forwarded connection
@@ -1263,17 +1264,17 @@
   -p [<listen_host>:]<listen_port> Run an HTTP proxy
 
 Output options:
-  -n No color in GUI (faster and consumes less RAM)
-  -c Extra color (colorizes escaped characters)
-  -r Show carriage returns (ASCII 13)
-  -s Output to stdout instead of a Tkinter window
+  -s   Output to stdout instead of a Tkinter window
+  -n   No color in GUI (faster and consumes less RAM)
+  -c   Extra color (colorizes escaped characters)
+  --cr     Show carriage returns (ASCII 13)
+  --help   Show usage information
 
 Recording options:
-  -R (or --record-directory) <path>
+  -r <path>  (synonyms: -R, --record-directory)
     Write recorded data to <path>.  By default, creates request and
     response files for each request, and writes a corresponding error file
-    for any error detected by tcpwatch.  Requires either running as an
-    HTTP proxy ('-p'), or with splitting turned on ('-h').
+    for any error detected by tcpwatch.
   --record-prefix=<prefix>
     Use <prefix> as the file prefix for logged request / response / error
     files (defaults to 'watch').
@@ -1281,12 +1282,12 @@
     Suppress writing '.response' files.
   --no-record-errors
     Suppress writing '.error' files.
-"""
+""")
     sys.exit()
 
 
 def usageError(s):
-    print >> sys.stderr, s
+    sys.stderr.write(str(s) + '\n\n')
     usage()
 
 
@@ -1294,8 +1295,8 @@
     global show_cr
 
     try:
-        optlist, extra = getopt.getopt(args, 'chL:np:rsR:',
-                                       ['help', 'http',
+        optlist, extra = getopt.getopt(args, 'chL:np:r:R:s',
+                                       ['help', 'http', 'cr',
                                         'record-directory=', 'record-prefix='
                                         'no-record-responses',
                                         'no-record-errors',
@@ -1324,7 +1325,7 @@
             colorized = 0
         elif option == '-c':
             colorized = 2
-        elif option == '-r':
+        elif option == '--cr':
             show_cr = 1
         elif option == '-s':
             show_config = 1
@@ -1362,7 +1363,9 @@
                 usageError('-L requires 2, 3, or 4 colon-separated parameters')
             fwd_params.append(
                 (listen_host, listen_port, dest_host, dest_port))
-        elif option == '-R' or option == '--record-directory':
+        elif (option == '-r'
+              or option == '-R'
+              or option == '--record-directory'):
             record_directory = value
         elif option == '--record-prefix':
             record_prefix = value
@@ -1372,10 +1375,7 @@
             record_errors = 0
 
     if not fwd_params and not proxy_params:
-        usage()
-
-    if record_directory and not split_http and not proxy_params:
-        usageError( 'Recording requires enabling either proxy or splitting.' )
+        usageError("At least one -L or -p option is required.")
 
     # Prepare the configuration display.
     config_info_lines = []
@@ -1419,7 +1419,12 @@
         def _factory(fci, sub_factory=obs_factory):
             return HTTPConnectionSplitter(sub_factory, fci)
         chosen_factory = _factory
-    
+    # obs_factory is the connection observer factory without HTTP
+    # connection splitting, while chosen_factory may have connection
+    # splitting.  Proxy services use obs_factory rather than the full
+    # chosen_factory because proxy services perform connection
+    # splitting internally.
+
     services = []
     try:
         # Start forwarding services.
@@ -1430,18 +1435,18 @@
 
         # Start proxy services.
         for params in proxy_params:
-            args = params + (obs_factory,)  # Don't parse HTTP twice.
+            args = params + (obs_factory,)
             s = HTTPProxyService(*args)
             services.append(s)
 
         if show_config:
-            print config_info
+            sys.stderr.write(config_info + '\n')
 
         # Run the main loop.
         try:
             asyncore.loop(timeout=1.0)
         except KeyboardInterrupt:
-            print >> sys.stderr, 'TCPWatch finished.'
+            sys.stderr.write('TCPWatch finished.\n')
     finally:
         for s in services:
             s.close()

=== Removed File Packages/tcpwatch/MANIFEST.in ===

=== Removed File Packages/tcpwatch/launch ===

=== Removed File Packages/tcpwatch/setup.cfg ===