imapt : add -l/--list parameter
This commit is contained in:
parent
276dcf6550
commit
329b11d8b7
1 changed files with 19 additions and 6 deletions
25
imapt
25
imapt
|
@ -91,6 +91,13 @@ parser.add_option('-v',
|
||||||
action="store_true",
|
action="store_true",
|
||||||
dest="verbose")
|
dest="verbose")
|
||||||
|
|
||||||
|
parser.add_option('-l',
|
||||||
|
'--list',
|
||||||
|
action="store_true",
|
||||||
|
dest="list",
|
||||||
|
help="List mailboxes",
|
||||||
|
default=False)
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
|
@ -141,14 +148,20 @@ if options.user:
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logging.debug("Select mailbox")
|
if options.list:
|
||||||
ret = server.select(options.mailbox)
|
logging.info('List mailbox')
|
||||||
if len(ret)>0 and ret[0]=='OK':
|
(status,l) = server.list()
|
||||||
logging.info("Mailbox %s content %s message(s)" % (options.mailbox,ret[1][0]))
|
for d in l:
|
||||||
|
logging.info(' "%s"' % d)
|
||||||
else:
|
else:
|
||||||
logging.error("Selecting return incorrected : %s" % ret)
|
logging.debug("Select mailbox")
|
||||||
|
ret = server.select(options.mailbox)
|
||||||
|
if len(ret)>0 and ret[0]=='OK':
|
||||||
|
logging.info("Mailbox %s content %s message(s)" % (options.mailbox,ret[1][0]))
|
||||||
|
else:
|
||||||
|
logging.error("Selecting return incorrected : %s" % ret)
|
||||||
|
server.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.critical('Error selecting mailbox %s : %s' % (option.mailbox,e))
|
logging.critical('Error selecting mailbox %s : %s' % (option.mailbox,e))
|
||||||
finally:
|
finally:
|
||||||
server.close()
|
|
||||||
server.logout()
|
server.logout()
|
||||||
|
|
Loading…
Reference in a new issue