smptlib frustration!

Peter Hansen peter at engcorp.com
Sat May 15 00:13:23 EDT 2004


Joe wrote:

> Ok I have written a perfectly well working script that uses smptlib
> module to email myself if the script ended in success or failure. 
> However, this module automatically outputs the results to the console
> to show the status of the connection/send/recieve etc...  This is a
> big problem for me.  I am trying to run this script from Backup Exec
> as a pre-processing job.  This causes my script to always fail because
> Backup Exec pre-processing jobs can not output to a console!  What am
> I to do?  Is there a way to stop this module from outputing the status
> to the console without having to actually modify the standard module? 

If you must do this from within the program rather than being
able to do the simplest thing, which is to use redirection to
dump the output to nowhere... (/dev/null or >nil depending on
your OS, if it's Linux or Win32)... then you can use something
like this:

  import sys
  class Sink:
      def write_null(self, *pargs):
          pass
  sys.stdout = sys.stderr = Sink()

There may be a simplification possible, but it's been a while since
I've had to do that...

-Peter



More information about the Python-list mailing list