view roundup/scripts/roundup_xmlrpc_server.py @ 3945:1dd64778bc45

Mail improvements: - Implement new config option in mail-section "ignore_alternatives" to ignore alternatives in a multipart/alternative mail. The *last* text/plain part of the *first* multipart/alternative is used as the message, if ignore_alternatives is set all other alternative parts of the first multipart/alternative that contained a text/plain part are ignored. Other multipart/alternative or other multipart are attached as before. This fixes [SF#959811] "Multipart/alternative handling considered bad". Note that this also changes which text/plain part is attached as the message if there are several text/plain parts in a multipart: Previously the *first* text/plain would be attached. Now we attach the *last* one, this is more in line with rfc 2046, sec. 5.1.4. according to Philipp Gortan. - Fix bug in attachment of text parts: If there are multiple text/plain parts in a nested multipart, the previous code would attach the multipart serialisation instead of the text/plain serialisation as a file to the issue in some cases. - Add regression tests for the new config-option and bug-fixes above.
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Wed, 14 Nov 2007 14:57:47 +0000
parents cf6c45201980
children edf526c91412
line wrap: on
line source

#! /usr/bin/env python
#
# Copyright (C) 2007 Stefan Seefeld
# All rights reserved.
# For license terms see the file COPYING.txt.
#

import getopt, os, sys, socket
from roundup.xmlrpc import RoundupServer, RoundupRequestHandler
from roundup.instance import TrackerError
from SimpleXMLRPCServer import SimpleXMLRPCServer

def usage():
    print """

Options:
 -i instance home  -- specify the issue tracker "home directory" to administer
 -V                -- be verbose when importing
 -p, --port <port> -- port to listen on

"""

def run():

    try:
        opts, args = getopt.getopt(sys.argv[1:],
                                   'e:i:p:V', ['encoding=', 'port='])
    except getopt.GetoptError, e:
        usage()
        return 1

    verbose = False
    tracker = ''
    port = 8000
    encoding = None

    for opt, arg in opts:
        if opt == '-V':
            verbose = True
        elif opt == '-i':
            tracker = arg
        elif opt in ['-p', '--port']:
            port = int(arg)
        elif opt in ['-e', '--encoding']:
            encoding = encoding

        if sys.version_info[0:2] < (2,5):
            if encoding:
                print 'encodings not supported with python < 2.5'
                sys.exit(-1)
            server = SimpleXMLRPCServer(('', port), RoundupRequestHandler)
        else:
            server = SimpleXMLRPCServer(('', port), RoundupRequestHandler,
                                        allow_none=True, encoding=encoding)
    if not os.path.exists(tracker):
        print 'Instance home does not exist.'
        sys.exit(-1)
    try:
        object = RoundupServer(tracker, verbose)
    except TrackerError:
        print 'Instance home does not exist.'
        sys.exit(-1)

    server.register_instance(object)

    # Go into the main listener loop
    print 'Roundup XMLRPC server started on %s:%d' \
          % (socket.gethostname(), port)
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        print 'Keyboard Interrupt: exiting'

if __name__ == '__main__':
    run()

Roundup Issue Tracker: http://roundup-tracker.org/