mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 19:20:12 +01:00
Added before/since date support to imapfetch.py
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
d2512f0cff
commit
0d1e34007e
@ -70,7 +70,7 @@ def process_folder(conn, folder):
|
|||||||
cursor.execute("UPDATE import SET status=%s, total=total+%s WHERE id=%s", data)
|
cursor.execute("UPDATE import SET status=%s, total=total+%s WHERE id=%s", data)
|
||||||
opts['db'].commit()
|
opts['db'].commit()
|
||||||
|
|
||||||
rc, data = conn.search(None, 'ALL')
|
rc, data = conn.search(None, opts['search'])
|
||||||
for num in data[0].split():
|
for num in data[0].split():
|
||||||
rc, data = conn.fetch(num, '(RFC822)')
|
rc, data = conn.fetch(num, '(RFC822)')
|
||||||
if opts['verbose']:
|
if opts['verbose']:
|
||||||
@ -92,6 +92,8 @@ def main():
|
|||||||
default="junk,trash,spam,draft")
|
default="junk,trash,spam,draft")
|
||||||
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," +
|
||||||
|
"eg. (BEFORE \"01-Jan-2020\") or (SINCE \"01-Jan-2020\")")
|
||||||
parser.add_argument("-d", "--dir", help="directory to chdir",
|
parser.add_argument("-d", "--dir", help="directory to chdir",
|
||||||
default="/var/piler/imap")
|
default="/var/piler/imap")
|
||||||
parser.add_argument("-i", "--import-from-table", action='store_true',
|
parser.add_argument("-i", "--import-from-table", action='store_true',
|
||||||
@ -108,10 +110,14 @@ def main():
|
|||||||
|
|
||||||
opts['skip_folders'] = args.skip_list.split(',')
|
opts['skip_folders'] = args.skip_list.split(',')
|
||||||
opts['verbose'] = args.verbose
|
opts['verbose'] = args.verbose
|
||||||
|
opts['search'] = 'ALL'
|
||||||
opts['counter'] = 0
|
opts['counter'] = 0
|
||||||
opts['db'] = None
|
opts['db'] = None
|
||||||
opts['id'] = 0
|
opts['id'] = 0
|
||||||
|
|
||||||
|
if args.date:
|
||||||
|
opts['search'] = args.date
|
||||||
|
|
||||||
server = ''
|
server = ''
|
||||||
user = ''
|
user = ''
|
||||||
password = ''
|
password = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user