"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "roundup/scripts/roundup_mailgw.py" between
roundup-1.6.1.tar.gz and roundup-2.0.0.tar.gz

About: Roundup is an highly customisable issue-tracking system with command-line, web and e-mail interfaces (written in Python).

roundup_mailgw.py  (roundup-1.6.1):roundup_mailgw.py  (roundup-2.0.0)
skipping to change at line 19 skipping to change at line 19
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
# #
# BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
"""Command-line script stub that calls the roundup.mailgw. """Command-line script stub that calls the roundup.mailgw.
""" """
from __future__ import print_function
__docformat__ = 'restructuredtext' __docformat__ = 'restructuredtext'
# --- patch sys.path to make sure 'import roundup' finds correct version # --- patch sys.path to make sure 'import roundup' finds correct version
import sys import sys
import os.path as osp import os.path as osp
thisdir = osp.dirname(osp.abspath(__file__)) thisdir = osp.dirname(osp.abspath(__file__))
rootdir = osp.dirname(osp.dirname(thisdir)) rootdir = osp.dirname(osp.dirname(thisdir))
if (osp.exists(thisdir + '/__init__.py') and if (osp.exists(thisdir + '/__init__.py') and
osp.exists(rootdir + '/roundup/__init__.py')): osp.exists(rootdir + '/roundup/__init__.py')):
# the script is located inside roundup source code # the script is located inside roundup source code
sys.path.insert(0, rootdir) sys.path.insert(0, rootdir)
# --/ # --/
# python version check # python version check
from roundup import version_check from roundup import version_check
from roundup import __version__ as roundup_version from roundup import __version__ as roundup_version
import sys, os, re, cStringIO, getopt, socket, netrc import sys, os, re, getopt, socket, netrc
from roundup import mailgw from roundup import mailgw
from roundup.i18n import _ from roundup.i18n import _
def usage(args, message=None): def usage(args, message=None):
if message is not None: if message is not None:
print message print(message)
print _( print(_(
"""Usage: %(program)s [-v] [-c class] [[-C class] -S field=value]* [instance hom """Usage: %(program)s [-v] [-c class] [[-C class] -S field=value]* [inst
e] [mail source [specification]] ance home] [mail source [specification]]
Options: Options:
-v: print version and exit -v: print version and exit
-c: default class of item to create (else the tracker's MAIL_DEFAULT_CLASS) -c: default class of item to create (else the tracker's MAIL_DEFAULT_CLASS)
-C / -S: see below -C / -S: see below
The roundup mail gateway may be called in one of the following ways: The roundup mail gateway may be called in one of the following ways:
. without arguments. Then the env var ROUNDUP_INSTANCE will be tried. . without arguments. Then the env var ROUNDUP_INSTANCE will be tried.
. with an instance home as the only argument, . with an instance home as the only argument,
. with both an instance home and a mail spool file, . with both an instance home and a mail spool file,
skipping to change at line 124 skipping to change at line 125
IMAPS: IMAPS:
Connect to an IMAP server over ssl. Connect to an IMAP server over ssl.
This supports the same notation as IMAP. This supports the same notation as IMAP.
imaps username:password@server [mailbox] imaps username:password@server [mailbox]
IMAPS_CRAM: IMAPS_CRAM:
Connect to an IMAP server over ssl using CRAM-MD5 authentication. Connect to an IMAP server over ssl using CRAM-MD5 authentication.
This supports the same notation as IMAP. This supports the same notation as IMAP.
imaps_cram username:password@server [mailbox] imaps_cram username:password@server [mailbox]
""")%{'program': args[0]} """) % {'program': args[0]})
return 1 return 1
def main(argv): def main(argv):
'''Handle the arguments to the program and initialise environment. '''Handle the arguments to the program and initialise environment.
''' '''
# take the argv array and parse it leaving the non-option # take the argv array and parse it leaving the non-option
# arguments in the args array. # arguments in the args array.
try: try:
optionsList, args = getopt.getopt(argv[1:], 'vc:C:S:', ['set=', optionsList, args = getopt.getopt(argv[1:], 'vc:C:S:', ['set=',
'class=']) 'class='])
except getopt.GetoptError: except getopt.GetoptError:
# print help information and exit: # print help information and exit:
usage(argv) usage(argv)
sys.exit(2) sys.exit(2)
for (opt, arg) in optionsList: for (opt, _arg) in optionsList:
if opt == '-v': if opt == '-v':
print '%s (python %s)'%(roundup_version, sys.version.split()[0]) print('%s (python %s)' % (roundup_version, sys.version.split()[0]))
return return
# figure the instance home # figure the instance home
if len(args) > 0: if len(args) > 0:
instance_home = args[0] instance_home = args[0]
else: else:
instance_home = os.environ.get('ROUNDUP_INSTANCE', '') instance_home = os.environ.get('ROUNDUP_INSTANCE', '')
if not (instance_home and os.path.isdir(instance_home)): if not (instance_home and os.path.isdir(instance_home)):
return usage(argv) return usage(argv)
skipping to change at line 168 skipping to change at line 169
handler = instance.MailGW(instance, optionsList) handler = instance.MailGW(instance, optionsList)
else: else:
handler = mailgw.MailGW(instance, optionsList) handler = mailgw.MailGW(instance, optionsList)
# if there's no more arguments, read a single message from stdin # if there's no more arguments, read a single message from stdin
if len(args) == 1: if len(args) == 1:
return handler.do_pipe() return handler.do_pipe()
# otherwise, figure what sort of mail source to handle # otherwise, figure what sort of mail source to handle
if len(args) < 3: if len(args) < 3:
return usage(argv, _('Error: not enough source specification information return usage(argv, _(
')) 'Error: not enough source specification information'))
source, specification = args[1:3] source, specification = args[1:3]
# time out net connections after a minute if we can # time out net connections after a minute if we can
if source not in ('mailbox', 'imaps', 'imaps_cram'): if source not in ('mailbox', 'imaps', 'imaps_cram'):
if hasattr(socket, 'setdefaulttimeout'): if hasattr(socket, 'setdefaulttimeout'):
socket.setdefaulttimeout(60) socket.setdefaulttimeout(60)
if source == 'mailbox': if source == 'mailbox':
return handler.do_mailbox(specification) return handler.do_mailbox(specification)
skipping to change at line 202 skipping to change at line 204
if match: if match:
username = match.group('user') username = match.group('user')
password = match.group('pass') password = match.group('pass')
server = match.group('server') server = match.group('server')
else: else:
return usage(argv, _('Error: %s specification not valid') % source) return usage(argv, _('Error: %s specification not valid') % source)
# now invoke the mailgw handler depending on the server handler requested # now invoke the mailgw handler depending on the server handler requested
if source.startswith('pop'): if source.startswith('pop'):
ssl = source.endswith('s') ssl = source.endswith('s')
if ssl and sys.version_info<(2,4):
return usage(argv, _('Error: a later version of python is required')
)
return handler.do_pop(server, username, password, ssl) return handler.do_pop(server, username, password, ssl)
elif source == 'apop': elif source == 'apop':
return handler.do_apop(server, username, password) return handler.do_apop(server, username, password)
elif source.startswith('imap'): elif source.startswith('imap'):
ssl = cram = 0 ssl = cram = 0
if source.endswith('s'): if source.endswith('s'):
ssl = 1 ssl = 1
elif source.endswith('s_cram'): elif source.endswith('s_cram'):
ssl = cram = 1 ssl = cram = 1
mailbox = '' mailbox = ''
if len(args) > 3: if len(args) > 3:
mailbox = args[3] mailbox = args[3]
return handler.do_imap(server, username, password, mailbox, ssl, return handler.do_imap(server, username, password, mailbox, ssl,
cram) cram)
return usage(argv, _('Error: The source must be either "mailbox",' return usage(argv, _('Error: The source must be either "mailbox",'
' "pop", "pops", "apop", "imap", "imaps" or "imaps_cram')) ' "pop", "pops", "apop", "imap", "imaps" or'
' "imaps_cram'))
def run(): def run():
sys.exit(main(sys.argv)) sys.exit(main(sys.argv))
# call main # call main
if __name__ == '__main__': if __name__ == '__main__':
run() run()
# vim: set filetype=python ts=4 sw=4 et si # vim: set filetype=python ts=4 sw=4 et si
 End of changes. 11 change blocks. 
16 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)