[PATCH] misc. cleanups
Nathaniel Smith
njs at pobox.com
Fri Aug 15 06:23:42 UTC 2003
Went through my list of assorted QMTest gripes today, so here's a
patch with all the trivial changes.
-- Nathaniel
--
Details are all that matters; God dwells there, and you never get to
see Him if you don't struggle to get them right. -- Stephen Jay Gould
-------------- next part --------------
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=__version.py --exclude=thread_target --exclude=process_target qm-clean/ChangeLog qm-misc-cleanups/ChangeLog
--- qm-clean/ChangeLog 2003-08-14 23:20:43.000000000 -0700
+++ qm-misc-cleanups/ChangeLog 2003-08-14 22:51:22.000000000 -0700
@@ -1,5 +1,22 @@
2003-08-14 Nathaniel Smith <njs at codesourcery.com>
+ * qm/executable.py (Executable.Spawn): Remove __has_*_run variables.
+ (Executable._InitializeParent): Likewise.
+ (Executable._HandleChild): Likewise.
+ (Executable._InitializeChild): Likewise.
+ (Executable._DoParent): Likewise.
+ * qm/platform_win32.py (get_user_name): Remove.
+ * qm/platform_unix.py (send_email): Remove.
+ (get_user_name): Remove.
+ * qm/regression_test.py: Remove file.
+
+ * qm/test/doc/reference.xml (Field Classes): Fix typo.
+
+ * qm/test/file_result_stream.py (FileResultStream.__init__): Fix
+ indentation.
+
+2003-08-14 Nathaniel Smith <njs at codesourcery.com>
+
* qm/executable.py (TimeoutExecutable._HandleChild): Close all
fds in the monitor process.
* tests/xmldb/test.qms/classes.qms/scripttest_closes_stdin.qmt:
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=__version.py --exclude=thread_target --exclude=process_target qm-clean/qm/executable.py qm-misc-cleanups/qm/executable.py
--- qm-clean/qm/executable.py 2003-08-14 23:20:43.000000000 -0700
+++ qm-misc-cleanups/qm/executable.py 2003-08-14 22:46:17.000000000 -0700
@@ -97,15 +97,6 @@
path using 'dir' as the base, or the current directory if
'dir' is not set."""
- # None of the hook functions have been run yet. These flags
- # are maintained so as to support multiple inheritance; in
- # that situation these functions in this class may be called
- # more than once.
- self.__has_initialize_child_run = 0
- self.__has_initialize_parent_run = 0
- self.__has_handle_child_run = 1
- self.__has_do_parent_run = 0
-
# Remember the directory in which the execution will occur.
self.__dir = dir
@@ -272,10 +263,8 @@
explaining how the child should be initialized. On other
systems, the return value is ignored."""
- if not self.__has_initialize_parent_run:
- self.__has_initialize_parent_run = 1
- if sys.platform == "win32":
- return win32process.STARTUPINFO()
+ if sys.platform == "win32":
+ return win32process.STARTUPINFO()
def _HandleChild(self):
@@ -287,7 +276,7 @@
Derived class versions must call this method."""
- self.__has_handle_child_run = 1
+ pass
def _InitializeChild(self):
@@ -301,16 +290,14 @@
assert sys.platform != "win32"
- if not self.__has_initialize_child_run:
- self.__has_initialize_child_run = 1
- if self.__dir:
- os.chdir(self.__dir)
+ if self.__dir:
+ os.chdir(self.__dir)
def _DoParent(self):
"""Perform actions required in the parent after 'Spawn'."""
- self.__has_do_parent_run = 1
+ pass
def _GetChildPID(self):
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=__version.py --exclude=thread_target --exclude=process_target qm-clean/qm/platform_unix.py qm-misc-cleanups/qm/platform_unix.py
--- qm-clean/qm/platform_unix.py 2003-08-14 23:20:43.000000000 -0700
+++ qm-misc-cleanups/qm/platform_unix.py 2003-08-14 22:44:02.000000000 -0700
@@ -93,128 +93,6 @@
os.system("%s '%s' &" % (browser, url))
-def send_email(body_text,
- subject,
- recipients,
- ccs=[],
- bccs=[],
- from_address=None,
- attachments=[],
- headers={}):
- """Send an email message.
-
- 'body_text' -- The message body text.
-
- 'subject' -- The message subject.
-
- 'recipients' -- A sequence of email addresses of message
- recipients.
-
- 'ccs' -- A sequence of email addresses of recipients of carbon
- copies.
-
- 'bccs' -- A sequence of email addresses of recipients of blind
- carbon copies.
-
- 'from_address' -- The message's originating address. If 'None',
- the system will fill in the sending user's address.
-
- 'attachments' -- A sequence of email attachments. Each attachment
- is a tuple containing '(description, mime_type, file_name,
- attachment_data)'. An appropriate encoding is chosen for the data
- based on the MIME type.
-
- 'headers' -- Additional RFC 822 headers in a map. Keys are
- header names and values are corresponding header contents."""
-
- # Figure out which sendmail (or equivalent) to use.
- sendmail_path = common.rc.Get("sendmail", "/usr/lib/sendmail",
- "common")
- # Make sure it exists and is executable.
- if not os.access(sendmail_path, os.X_OK):
- raise common.QMException, \
- qm.error("sendmail error",
- sendmail_path=sendmail_path)
-
- # Start a sendmail process.
- addresses = map(lambda a: "'%s'" % a, recipients + ccs + bccs)
- sendmail_command = sendmail_path + " " + string.join(addresses, " ")
- sendmail = os.popen(sendmail_command, "w")
- message = MimeWriter.MimeWriter(sendmail)
-
- # Construct mail headers.
- if from_address is not None:
- message.addheader("From", from_address)
- message.addheader("To", string.join(recipients, ", "))
- if len(ccs) > 0:
- message.addheader("CC", string.join(ccs, ", "))
- if len(bccs) > 0:
- message.addheader("BCC", string.join(bccs, ", "))
- for name, value in headers.items():
- message.addheader(name, value)
- message.addheader("Subject", subject)
-
- # Handle messages with attachments differently.
- if len(attachments) > 0:
- # Set the MIME version header.
- message.addheader("MIME-Version", "1.0")
- # A message with attachments has a content type
- # "multipart/mixed".
- body = message.startmultipartbody("mixed")
-
- # The text of the message body goes in the first message part.
- body_part = message.nextpart()
- body_part.addheader("Content-Description", "message body text")
- body_part.addheader("Content-Transfer-Encoding", "7bit")
- body_part_body = body_part.startbody("text/plain")
- body_part_body.write(body_text)
-
- # Add the attachments, each in a separate message part.
- for attachment in attachments:
- # Unpack the attachment tuple.
- description, mime_type, file_name, data = attachment
- # Choose an encoding based on the MIME type.
- if mime_type == "text/plain":
- # Plain text encoded as-is.
- encoding = "7bit"
- elif mime_type[:4] == "text":
- # Other types of text are encoded quoted-printable.
- encoding = "quoted-printable"
- else:
- # Everything else is base 64-encoded.
- encoding = "base64"
- # Create a new message part for the attachment.
- part = message.nextpart()
- part.addheader("Content-Description", description)
- part.addheader("Content-Disposition",
- 'attachment; filename="%s"' % file_name)
- part.addheader("Content-Transfer-Encoding", encoding)
- part_body = part.startbody('%s; name="%s"'
- % (mime_type, file_name))
- # Write the attachment data, encoded appropriately.
- if encoding is "7bit":
- part_body.write(data)
- elif encoding is "quoted-printable":
- quopri.encode(cStringIO.StringIO(data), part_body, quotetabs=0)
- elif encoding is "base64":
- base64.encode(cStringIO.StringIO(data), part_body)
-
- # End the multipart message.
- message.lastpart()
-
- else:
- # If the message has no attachments, don't use a multipart
- # format. Instead, just write the essage bdoy.
- body = message.startbody("text/plain")
- body.write(body_text)
-
- # Finish up.
- exit_code = sendmail.close()
- if exit_code is not None:
- raise MailError, "%s returned with exit code %d" \
- % (sendmail_path, exit_code)
-
-
def get_signal_name(signal_number):
"""Return the name for signal 'signal_number'.
@@ -246,23 +124,6 @@
raise SignalException(signal_number)
-def get_user_name():
- """Return the name user running the current program."""
-
- # Get the numerical user ID.
- user_id = os.getuid()
- # To convert it to a name, we have to consult the system password file.
- for line in open("/etc/passwd", "r").readlines():
- # Each row is constructed of parts delimited by colons.
- parts = string.split(line, ":")
- # The third element is the user ID. Does it match?
- if int(parts[2]) == user_id:
- # Yes. Return the first part, the user name.
- return parts[0]
- # No match.
- raise common.QMException, "user not found in /etc/passwd"
-
-
def get_host_name():
"""Return the name of this computer."""
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=__version.py --exclude=thread_target --exclude=process_target qm-clean/qm/platform_win32.py qm-misc-cleanups/qm/platform_win32.py
--- qm-clean/qm/platform_win32.py 2003-08-14 23:20:43.000000000 -0700
+++ qm-misc-cleanups/qm/platform_win32.py 2003-08-14 22:44:29.000000000 -0700
@@ -48,12 +48,6 @@
# functions
########################################################################
-def get_user_name():
- """Return the name user running the current program."""
-
- return os.environ["USERNAME"]
-
-
def get_host_name():
"""Return the name of this computer."""
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=__version.py --exclude=thread_target --exclude=process_target qm-clean/qm/regression_test.py qm-misc-cleanups/qm/regression_test.py
--- qm-clean/qm/regression_test.py 2003-08-14 23:20:43.000000000 -0700
+++ qm-misc-cleanups/qm/regression_test.py 1969-12-31 16:00:00.000000000 -0800
@@ -1,93 +0,0 @@
-########################################################################
-#
-# File: regression_test.py
-# Author: Alex Samuel
-# Date: 2000-12-20
-#
-# Contents:
-# Very simple provisional regression test framework for qm components
-# to tie us over until qmtest is up and running.
-#
-# Copyright (c) 2000 by CodeSourcery, LLC. All rights reserved.
-#
-# For license terms see the file COPYING.
-#
-########################################################################
-
-########################################################################
-# imports
-########################################################################
-
-import getopt
-import string
-import sys
-import traceback
-
-########################################################################
-# functions
-########################################################################
-
-def run_regression_test_driver(regression_tests):
- """Run regression tests.
-
- Each regression test is a callable object that takes zero
- arguments, and returns a true value if the test passes or a false
- value if the test failes. Exits the program with a zero exit code
- if all tests pass, or with a non-zero exit code if some tests
- fail.
-
- 'regression_tests' -- A sequence of regression tests."""
-
- keep_going = 0
- verbosity = 0
-
- # Parse command-line options.
- options, args = getopt.getopt(sys.argv[1:], "kv")
- for option, option_arg in options:
- if option == "-k":
- keep_going = 1
- elif option == "-v":
- verbosity = verbosity + 1
-
- def message(min_verbosity, message_text, verbosity=verbosity):
- if verbosity >= min_verbosity:
- sys.stdout.write(message_text)
-
- # Count failures.
- failures = 0
- # Run tests.
- for test in regression_tests:
- # Invoke the test, handling all exceptions.
- try:
- result = apply(test, ())
- exception = None
- except:
- exception = sys.exc_info()
-
- # Print the result.
- message(1, "test %-40s: " % ('"' + test.__name__ + '"'))
- if exception != None:
- # The test raised an unhandled exception. Print a
- # traceback and the exception info.
- message(1, "unhandled exception\n")
- message(2, "Traceback:\n"
- + string.join(traceback.format_tb(exception[2]), "")
- + "\n%s: %s\n" % (exception[0], exception[1]))
- failures = failures + 1
- # Don't continue past an exception, unless asked to.
- if not keep_going:
- break
- elif result:
- message(1, "passed\n")
- else:
- message(1, "failed\n")
- failures = failures + 1
-
- return failures
-
-
-########################################################################
-# Local Variables:
-# mode: python
-# indent-tabs-mode: nil
-# End:
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=__version.py --exclude=thread_target --exclude=process_target qm-clean/qm/test/doc/reference.xml qm-misc-cleanups/qm/test/doc/reference.xml
--- qm-clean/qm/test/doc/reference.xml 2003-08-14 23:20:43.000000000 -0700
+++ qm-misc-cleanups/qm/test/doc/reference.xml 2003-08-14 22:38:45.000000000 -0700
@@ -2070,7 +2070,7 @@
<para>A &field_class; is a named, typed component of a data
structure. A <classname>Field</classname> can read and write XML
representations of values, generate HTML representations of values,
- or present HTML forms that permit the user to pudate the value of
+ or present HTML forms that permit the user to update the value of
the field. There are several classes derived from
<classname>Field</classname> that you can use in extension classes.
If none of those classes satisfy your needs, you can create a new
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=config.cache --exclude=qmtest --exclude=qm.spec --exclude='*.html' --exclude='*.dtd' --exclude=CATALOG --exclude=__version.py --exclude=thread_target --exclude=process_target qm-clean/qm/test/file_result_stream.py qm-misc-cleanups/qm/test/file_result_stream.py
--- qm-clean/qm/test/file_result_stream.py 2003-08-14 23:20:43.000000000 -0700
+++ qm-misc-cleanups/qm/test/file_result_stream.py 2003-08-14 22:51:14.000000000 -0700
@@ -64,7 +64,7 @@
mode = "wb"
else:
mode = "w"
- self.file = open(self.filename, mode, 0)
+ self.file = open(self.filename, mode, 0)
else:
self.file = sys.stdout
Binary files qm-clean/results.qmr and qm-misc-cleanups/results.qmr differ
More information about the qmtest
mailing list