-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpymm.py
executable file
·77 lines (60 loc) · 2.35 KB
/
pymm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/python3
##
## pymm.py
##
## Created on: Oct 21, 2012
## Author: martinez
##
VERSION = 'pymm 0.1.1'
import sys
import optparse
import logging
from coloredformatter import ColoredFormatter
logger = logging.getLogger('pymm')
from massmail import MassMail
if __name__ == "__main__":
logger.setLevel(logging.WARNING)
console = logging.StreamHandler()
console.setFormatter(
ColoredFormatter('%(name)s: %(message)s (%(filename)s:%(lineno)d)'))
logger.addHandler(console)
parser = optparse.OptionParser(usage = "usage: %prog [options] cfgfile",
version = VERSION)
parser.add_option("-i", "--initialize",
action="store_true", dest="initialize",
help="initialize an empty cfgfile and quit")
parser.add_option("--initialize-with-github-note",
action="store_true", dest="initialize_with_github_note",
help="initialize an empty cfgfile, add default git note"
" and quit")
parser.add_option("-v", action="store_true", dest="verbose",
help="show status messages (default)")
parser.add_option("-q", action="store_false", dest="verbose",
help="don't show status messages")
parser.add_option("-V", action="store_true", dest="debug",
help="print debug messages")
parser.set_defaults(initialize=False, initialize_with_github_note=False,
verbose=True, debug=False)
(options, args) = parser.parse_args()
logger.debug(str(args))
logger.debug(str(options))
if(options.verbose):
logger.setLevel(logging.INFO)
if(options.debug):
logger.setLevel(logging.DEBUG)
if(len(args) != 1):
parser.print_usage()
sys.exit(1)
cfgfile = args[0]
if(options.initialize or options.initialize_with_github_note):
if(not options.initialize_with_github_note):
MassMail.init_cfg_file(cfgfile,
note='Note: This message was automatically generated.')
else:
gitnote = """Note: This message was automatically generated by {}.
Please contact the author (jmartinez@gmx.de) regarding any issues.
=====>>> Fork me @ github: github.com/ph03/pymm ! <<<=====""".format(VERSION)
logger.debug(gitnote)
MassMail.init_cfg_file(cfgfile, note=gitnote)
sys.exit(0)
mm = MassMail(cfgfile)