Improved imapfetch.py

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2020-10-27 22:11:21 +01:00
parent 1d615a1967
commit f7f91c0855

View File

@ -91,11 +91,16 @@ def main():
default="junk,trash,spam,draft")
parser.add_argument("-f", "--folders", type=str,
help="Comma separated list of IMAP folders to download")
parser.add_argument("-i", "--import-from-table", help="Read imap conn data from import table", action='store_true')
parser.add_argument("-d", "--dir", help="directory to chdir",
default="/var/piler/imap")
parser.add_argument("-i", "--import-from-table", action='store_true',
help="Read imap conn data from import table")
parser.add_argument("-v", "--verbose", help="verbose mode", action='store_true')
args = parser.parse_args()
os.chdir(args.dir)
if not bool(args.import_from_table or args.server):
print("Please specify either --import-from-table or --server <imap host>")
sys.exit(1)
@ -158,10 +163,15 @@ def main():
conn.close()
if opts['db']:
subprocess.call(["pilerimport", "-d", "/var/piler/imap", "-r"])
if opts['id']:
subprocess.call(["pilerimport",
"-d", args.dir,
"-r",
"-T", str(opts['id'])])
opts['db'].close()
print("Processed {} messages".format(opts['counter']))
if __name__ == "__main__":
main()