|
| 1 | +#! /usr/bin/python |
| 2 | +# |
| 3 | +# Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/) |
| 4 | +# This module is free software, and you may redistribute it and/or modify |
| 5 | +# under the same terms as Python, so long as this copyright message and |
| 6 | +# disclaimer are retained in their original form. |
| 7 | +# |
| 8 | +# IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR |
| 9 | +# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING |
| 10 | +# OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE |
| 11 | +# POSSIBILITY OF SUCH DAMAGE. |
| 12 | +# |
| 13 | +# BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 14 | +# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 15 | +# FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 16 | +# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 17 | +# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 18 | +# |
| 19 | +# $Id: roundup-popgw,v 1.1 2001-11-01 22:07:11 richard Exp $ |
| 20 | + |
| 21 | +import sys |
| 22 | +if int(sys.version[0]) < 2: |
| 23 | + print "Roundup requires Python 2.0 or newer." |
| 24 | + sys.exit(1) |
| 25 | + |
| 26 | +# figure the instance home |
| 27 | +import os |
| 28 | +if len(sys.argv) > 1: |
| 29 | + instance_home = sys.argv[1] |
| 30 | +else: |
| 31 | + instance_home = os.environ.get('ROUNDUP_INSTANCE', '') |
| 32 | +if not instance_home: |
| 33 | + print 'No instance home specified' |
| 34 | + sys.exit(1) |
| 35 | + |
| 36 | +# get the instance |
| 37 | +import roundup.instance |
| 38 | +instance = roundup.instance.open(instance_home) |
| 39 | + |
| 40 | +# invoke the mail handler |
| 41 | +db = instance.open('admin') |
| 42 | +handler = instance.MailGW(db) |
| 43 | + |
| 44 | +import getpass, poplib |
| 45 | + |
| 46 | +M = poplib.POP3('localhost') |
| 47 | +M.user(getpass.getuser()) |
| 48 | +M.pass_(getpass.getpass()) |
| 49 | +numMessages = len(M.list()[1]) |
| 50 | +for i in range(numMessages): |
| 51 | + for j in M.retr(i+1)[1]: |
| 52 | + s = cStringIO.StringIO('\n'.join(j)) |
| 53 | + s.seek(0) |
| 54 | + handler.main(s) |
| 55 | + |
| 56 | +# |
| 57 | +# $Log: not supported by cvs2svn $ |
| 58 | +# |
| 59 | +# |
| 60 | +# vim: set filetype=python ts=4 sw=4 et si |
0 commit comments