Update of /cvsroot/leaf/CVSROOT
In directory sc8-pr-cvs1:/tmp/cvs-serv8851

Modified Files:
        syncmail 
Log Message:
updated to cvs-syncmail cvs -r 1.29

Index: syncmail
===================================================================
RCS file: /cvsroot/leaf/CVSROOT/syncmail,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** syncmail    4 May 2002 23:28:02 -0000       1.3
--- syncmail    19 Mar 2003 17:43:24 -0000      1.4
***************
*** 1,4 ****
--- 1,8 ----
  #! /usr/bin/python
  
+ # Copyright (c) 2002, Barry Warsaw, Fred Drake, and contributors
+ # All rights reserved.
+ # See the accompanying LICENSE file for details.
+ 
  # NOTE: Until SourceForge installs a modern version of Python on the cvs
  # servers, this script MUST be compatible with Python 1.5.2.
***************
*** 35,40 ****
  
      --cvsroot=<path>
!       Use <path> as the environment variable CVSROOT.  Otherwise this
!       variable must exist in the environment.
  
      --context=#
--- 39,44 ----
  
      --cvsroot=<path>
!         Use <path> as the environment variable CVSROOT.  Otherwise this
!         variable must exist in the environment.
  
      --context=#
***************
*** 45,51 ****
--- 49,68 ----
          Produce a context diff (default).
  
+     -m hostname
+     --mailhost hostname
+         The hostname of an available SMTP server.  The default is
+         'localhost'.
+ 
      -u
          Produce a unified diff (smaller).
  
+     -S TEXT
+     --subject-prefix=TEXT
+         Prepend TEXT to the email subject line.
+ 
+     -R ADDR
+     --reply-to=ADDR
+       Add a "Reply-To: ADDR" header to the email message.
+ 
      --quiet / -q
          Don't print as much status to stdout.
***************
*** 54,58 ****
      -f hostname
          The hostname that email messages appear to be coming from.  The From:
!         header will of the outgoing message will look like [EMAIL PROTECTED]  By
          default, hostname is the machine's fully qualified domain name.
  
--- 71,75 ----
      -f hostname
          The hostname that email messages appear to be coming from.  The From:
!         header of the outgoing message will look like [EMAIL PROTECTED]  By
          default, hostname is the machine's fully qualified domain name.
  
***************
*** 72,75 ****
--- 89,94 ----
          At least one email address.
  """
+ __version__ = '1.2'
+ 
  import os
  import sys
***************
*** 98,107 ****
              fqdn = 'localhost.localdomain'
          return fqdn
!     
  
  from cStringIO import StringIO
  
! # Which SMTP server to do we connect to?  Empty string means localhost.
! MAILHOST = ''
  MAILPORT = 25
  
--- 117,126 ----
              fqdn = 'localhost.localdomain'
          return fqdn
! 
  
  from cStringIO import StringIO
  
! # Which SMTP server to do we connect to?
! MAILHOST = 'localhost'
  MAILPORT = 25
  
***************
*** 137,141 ****
  
  def calculate_diff(filespec, contextlines):
!     file, oldrev, newrev = string.split(filespec, ',')
      # Make sure we can find a CVS version number
      if not REVCRE.match(oldrev):
--- 156,170 ----
  
  def calculate_diff(filespec, contextlines):
!     spec = string.split(filespec, ',')
!     if len(spec) < 3:
!         # Too few parts; command line probable used a replacement
!         # other than "%{sVv}"; don't fail, but don't produce a diff
!         # since we can't be sure what diff to generate.
!         return ''
!     # This allows filenames that contain commas:
!     file = string.join(spec[:-2], ",")
!     oldrev = spec[-2]
!     newrev = spec[-1]
! 
      # Make sure we can find a CVS version number
      if not REVCRE.match(oldrev):
***************
*** 163,166 ****
--- 192,196 ----
          filestr = "'" + file + "'"
      if oldrev == 'NONE':
+         # File is being added.
          try:
              if os.path.exists(file):
***************
*** 187,190 ****
--- 217,221 ----
          lines = ['--- %s DELETED ---\n' % file]
      else:
+         # File has been changed.
          # This /has/ to happen in the background, otherwise we'll run into CVS
          # lock contention.  What a crock.
***************
*** 210,214 ****
  
  
! def blast_mail(subject, people, filestodiff, contextlines, fromhost):
      # cannot wait for child process or that will cause parent to retain cvs
      # lock for too long.  Urg!
--- 241,255 ----
  
  
! rfc822_specials_re = re.compile(r'[\(\)\<\>[EMAIL PROTECTED],\;\:\\\"\.\[\]]')
! 
! def quotename(name):
!     if name and rfc822_specials_re.search(name):
!         return '"%s"' % string.replace(name, '"', '\\"')
!     else:
!         return name
! 
! 
! 
! def blast_mail(subject, people, filestodiff, contextlines, fromhost, replyto):
      # cannot wait for child process or that will cause parent to retain cvs
      # lock for too long.  Urg!
***************
*** 221,237 ****
          conn.connect(MAILHOST, MAILPORT)
          user = pwd.getpwuid(os.getuid())[0]
          domain = fromhost or getfqdn()
!         author = '[EMAIL PROTECTED]' % (user, domain)
          s = StringIO()
          sys.stdout = s
          try:
              print '''\
- From: %(author)s
- To: %(people)s
  Subject: %(subject)s
! ''' % {'author' : author,
!        'people' : string.join(people, COMMASPACE),
!        'subject': subject,
!        }
              s.write(sys.stdin.read())
              # append the diffs if available
--- 262,286 ----
          conn.connect(MAILHOST, MAILPORT)
          user = pwd.getpwuid(os.getuid())[0]
+         name = string.split(pwd.getpwuid(os.getuid())[4], ',')[0]
          domain = fromhost or getfqdn()
!         address = '[EMAIL PROTECTED]' % (user, domain)
          s = StringIO()
          sys.stdout = s
          try:
+             vars = {'address' : address,
+                     'name'    : quotename(name),
+                     'people'  : string.join(people, COMMASPACE),
+                     'subject' : subject,
+                     'version' : __version__,
+                     }
+             print '''\
+ From: %(name)s <%(address)s>
+ To: %(people)s''' % vars
+             if replyto:
+                 print 'Reply-To: %s' % replyto
              print '''\
  Subject: %(subject)s
! X-Mailer: Python syncmail %(version)s <http://sf.net/projects/cvs-syncmail>
! ''' % vars
              s.write(sys.stdin.read())
              # append the diffs if available
***************
*** 241,245 ****
          finally:
              sys.stdout = sys.__stdout__
!         resp = conn.sendmail(author, people, s.getvalue())
          conn.close()
          os._exit(0)
--- 290,294 ----
          finally:
              sys.stdout = sys.__stdout__
!         resp = conn.sendmail(address, people, s.getvalue())
          conn.close()
          os._exit(0)
***************
*** 249,256 ****
  # scan args for options
  def main():
      try:
          opts, args = getopt.getopt(
!             sys.argv[1:], 'hC:cuqf:',
!             ['fromhost=', 'context=', 'cvsroot=', 'help', 'quiet'])
      except getopt.error, msg:
          usage(1, msg)
--- 298,309 ----
  # scan args for options
  def main():
+     # XXX Should really move all the options to an object, just to
+     # avoid threading so many positional args through everything.
      try:
          opts, args = getopt.getopt(
!             sys.argv[1:], 'hC:cuS:R:qf:m:',
!             ['fromhost=', 'context=', 'cvsroot=', 'mailhost=',
!              'subject-prefix=', 'reply-to=',
!              'help', 'quiet'])
      except getopt.error, msg:
          usage(1, msg)
***************
*** 259,262 ****
--- 312,317 ----
      contextlines = 2
      verbose = 1
+     subject_prefix = ""
+     replyto = None
      fromhost = None
      for opt, arg in opts:
***************
*** 272,279 ****
--- 327,341 ----
          elif opt == '-u':
              contextlines = 0
+         elif opt in ('-S', '--subject-prefix'):
+             subject_prefix = arg
+         elif opt in ('-R', '--reply-to'):
+             replyto = arg
          elif opt in ('-q', '--quiet'):
              verbose = 0
          elif opt in ('-f', '--fromhost'):
              fromhost = arg
+         elif opt in ('-m', '--mailhost'):
+             global MAILHOST
+             MAILHOST = arg
  
      # What follows is the specification containing the files that were
***************
*** 283,287 ****
      if not args:
          usage(1, 'No CVS module specified')
!     subject = args[0]
      specs = string.split(args[0])
      del args[0]
--- 345,349 ----
      if not args:
          usage(1, 'No CVS module specified')
!     subject = subject_prefix + args[0]
      specs = string.split(args[0])
      del args[0]
***************
*** 297,301 ****
          print 'Mailing %s...' % string.join(people, COMMASPACE)
  
!     if specs == ['-', 'Imported', 'sources']:
          return
      if specs[-3:] == ['-', 'New', 'directory']:
--- 359,363 ----
          print 'Mailing %s...' % string.join(people, COMMASPACE)
  
!     if specs[-3:] == ['-', 'Imported', 'sources']:
          return
      if specs[-3:] == ['-', 'New', 'directory']:
***************
*** 313,317 ****
      if verbose:
          print 'Generating notification message...'
!     blast_mail(subject, people, specs[1:], contextlines, fromhost)
      if verbose:
          print 'Generating notification message... done.'
--- 375,379 ----
      if verbose:
          print 'Generating notification message...'
!     blast_mail(subject, people, specs[1:], contextlines, fromhost, replyto)
      if verbose:
          print 'Generating notification message... done.'




-------------------------------------------------------
This SF.net email is sponsored by: Does your code think in ink? 
You could win a Tablet PC. Get a free Tablet PC hat just for playing. 
What are you waiting for?
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en
_______________________________________________
Leaf-cvs-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/leaf-cvs-commits

Reply via email to