Mercurial > p > roundup > code
comparison roundup/scripts/roundup_mailgw.py @ 2186:3f89c8ffe4f1
version info in scripts
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 05 Apr 2004 23:43:04 +0000 |
| parents | fc52d57c6c3e |
| children | b61640273061 |
comparison
equal
deleted
inserted
replaced
| 2185:c52a931879c4 | 2186:3f89c8ffe4f1 |
|---|---|
| 12 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 12 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 13 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 13 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 16 # | 16 # |
| 17 # $Id: roundup_mailgw.py,v 1.11 2004-02-11 23:55:10 richard Exp $ | 17 # $Id: roundup_mailgw.py,v 1.12 2004-04-05 23:43:03 richard Exp $ |
| 18 | 18 |
| 19 """Command-line script stub that calls the roundup.mailgw. | 19 """Command-line script stub that calls the roundup.mailgw. |
| 20 """ | 20 """ |
| 21 __docformat__ = 'restructuredtext' | 21 __docformat__ = 'restructuredtext' |
| 22 | 22 |
| 23 # python version check | 23 # python version check |
| 24 from roundup import version_check | 24 from roundup import version_check |
| 25 from roundup import __version__ as roundup_version | |
| 25 | 26 |
| 26 import sys, os, re, cStringIO, getopt | 27 import sys, os, re, cStringIO, getopt |
| 27 | 28 |
| 28 from roundup.mailgw import Message | 29 from roundup.mailgw import Message |
| 29 from roundup.i18n import _ | 30 from roundup.i18n import _ |
| 30 | 31 |
| 31 def usage(args, message=None): | 32 def usage(args, message=None): |
| 32 if message is not None: | 33 if message is not None: |
| 33 print message | 34 print message |
| 34 print _('Usage: %(program)s [[-C class] -S field=value]* <instance ' | 35 print _('Usage: %(program)s [-v] [[-C class] -S field=value]* <instance ' |
| 35 'home> [method]')%{'program': args[0]} | 36 'home> [method]')%{'program': args[0]} |
| 36 print _(''' | 37 print _(''' |
| 38 Options: | |
| 39 -v: print version and exit | |
| 40 -C / -S: see below | |
| 37 | 41 |
| 38 The roundup mail gateway may be called in one of three ways: | 42 The roundup mail gateway may be called in one of three ways: |
| 39 . with an instance home as the only argument, | 43 . with an instance home as the only argument, |
| 40 . with both an instance home and a mail spool file, or | 44 . with both an instance home and a mail spool file, or |
| 41 . with both an instance home and a pop server account. | 45 . with both an instance home and a pop server account. |
| 83 '''Handle the arguments to the program and initialise environment. | 87 '''Handle the arguments to the program and initialise environment. |
| 84 ''' | 88 ''' |
| 85 # take the argv array and parse it leaving the non-option | 89 # take the argv array and parse it leaving the non-option |
| 86 # arguments in the args array. | 90 # arguments in the args array. |
| 87 try: | 91 try: |
| 88 optionsList, args = getopt.getopt(argv[1:], 'C:S:', ['set=', 'class=']) | 92 optionsList, args = getopt.getopt(argv[1:], 'vC:S:', ['set=', 'class=']) |
| 89 except getopt.GetoptError: | 93 except getopt.GetoptError: |
| 90 # print help information and exit: | 94 # print help information and exit: |
| 91 usage(argv) | 95 usage(argv) |
| 92 sys.exit(2) | 96 sys.exit(2) |
| 97 | |
| 98 for (opt, arg) in optionsList: | |
| 99 if opt == '-v': | |
| 100 print '%s (python %s)'%(roundup_version, sys.version.split()[0]) | |
| 101 return | |
| 93 | 102 |
| 94 # figure the instance home | 103 # figure the instance home |
| 95 if len(args) > 0: | 104 if len(args) > 0: |
| 96 instance_home = args[0] | 105 instance_home = args[0] |
| 97 else: | 106 else: |
