Added popt script
Benjamin Renard authored 11 years ago
|
1) #! /usr/bin/env python
2) # -*- coding: utf-8 -*-
3)
4) # popt -- Simple command-line tool to test IMAP server
5) # By: Benjamin RENARD <brenard@easter-eggs.com>
6) #
7) # Copyright (C) 2013 Easter-eggs
8) # http://git.zionetrix.net/mailt
9) #
10) # This file is part of MailT.
11) #
12) # MailT is free software; you can redistribute it and/or modify
13) # it under the terms of the GNU General Public License as published
14) # by the Free Software Foundation, either version 3 of the License,
15) # or (at your option) any later version.
16) #
17) # MailT is distributed in the hope that it will be useful,
18) # but WITHOUT ANY WARRANTY; without even the implied warranty of
19) # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20) # GNU Affero General Public License for more details.
21) #
22) # You should have received a copy of the GNU General Public License
23) # along with this program. If not, see <http://www.gnu.org/licenses/>.
24)
25) from optparse import OptionParser
26)
27) import os
28) import poplib
|
Added popt script
Benjamin Renard authored 11 years ago
|
30)
31) import logging
32) import sys
33)
34) parser = OptionParser()
35)
36)
37) parser.add_option('-H',
38) '--host',
39) action="store",
40) type="string",
41) dest="host",
42) help="The IMAP host",
43) default="127.0.0.1")
44)
45) parser.add_option('-p',
46) '--port',
47) action="store",
48) type="string",
49) dest="port",
50) help="The IMAP port",
51) default=None)
52)
53) parser.add_option('-S',
54) '--ssl',
55) action="store_true",
56) dest="ssl",
57) help="IMAP Over SSL (IMAPS)",
58) default=False)
59)
60) parser.add_option('-U',
61) '--user',
62) action="store",
63) type="string",
64) dest="user",
65) help="User login",
66) default=None)
67)
68) parser.add_option('-P',
69) '--password',
70) action="store",
71) type="string",
72) dest="password",
73) help="User password",
74) default=None)
75)
76) parser.add_option('-v',
77) '--verbose',
78) action="store_true",
79) dest="verbose")
80)
81) parser.add_option('-d',
82) '--debug',
83) action="store_true",
84) dest="debug")
85)
86) (options, args) = parser.parse_args()
87)
88) if options.verbose or options.debug:
89) loglevel=logging.DEBUG
90) else:
91) loglevel=logging.INFO
92)
93) logging.basicConfig(level=loglevel,format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
94)
|