Updated imapfetch.py

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2022-07-05 15:17:15 +02:00
parent e95e8496a7
commit 66f3d57b28

View File

@ -61,7 +61,16 @@ def process_folder(conn, folder):
if opts['verbose']: if opts['verbose']:
print("Processing {}".format(folder)) print("Processing {}".format(folder))
rc, data = conn.select(folder) try:
rc, data = conn.select(folder)
except:
print("Error processing folder {}".format(folder))
return
if rc != "OK":
print("Error processing folder {}, rc={}, response={}".format(folder, rc, data))
return
n = int(data[0]) n = int(data[0])
if opts['verbose']: if opts['verbose']:
print("Folder {} has {} messages".format(folder, n)) print("Folder {} has {} messages".format(folder, n))
@ -94,7 +103,7 @@ def main():
parser.add_argument("-u", "--user", type=str, help="imap user") parser.add_argument("-u", "--user", type=str, help="imap user")
parser.add_argument("-p", "--password", type=str, help="imap password") parser.add_argument("-p", "--password", type=str, help="imap password")
parser.add_argument("-x", "--skip-list", type=str, help="IMAP folders to skip", parser.add_argument("-x", "--skip-list", type=str, help="IMAP folders to skip",
default="junk,trash,spam,draft") default="junk,trash,spam,draft,\"[Gmail]\"")
parser.add_argument("-f", "--folders", type=str, parser.add_argument("-f", "--folders", type=str,
help="Comma separated list of IMAP folders to download") help="Comma separated list of IMAP folders to download")
parser.add_argument("--date", type=str, help="Search before/since a given date," + parser.add_argument("--date", type=str, help="Search before/since a given date," +