def main(args): import json, config import data import hooks hooks.invoke('scan.pre') notmuch_dir = config.get_notmuch_dir() mail_query = config.get_mail_query() search_days = config.get_search_days() trees = config.get_trees() def sort_patch(a, b): return cmp(b['messages'][0]['full_date'], a['messages'][0]['full_date']) patches = build_patches(notmuch_dir, search_days, mail_query, trees) patches.sort(sort_patch) links = config.get_links() info = { 'version': data.VERSION, 'patches': patches } if links: info['links'] = links replace_file(config.get_json_path(), json.dumps(info, indent=2, separators=(',', ': '), encoding='iso-8859-1')) hooks.invoke('scan.post') return 0
def main(args): import json, config import data import hooks hooks.invoke('scan.pre') notmuch_dir = config.get_notmuch_dir() mail_query = config.get_mail_query() search_days = config.get_search_days() trees = config.get_trees() def sort_patch(a, b): return cmp(b['messages'][0]['full_date'], a['messages'][0]['full_date']) patches = build_patches(notmuch_dir, search_days, mail_query, trees) patches.sort(sort_patch) links = config.get_links() info = {'version': data.VERSION, 'patches': patches} if links: info['links'] = links replace_file( config.get_json_path(), json.dumps(info, indent=2, separators=(',', ': '), encoding='iso-8859-1')) hooks.invoke('scan.post') return 0
def refresh(args): maildir = config.get_notmuch_dir() with open('%s/.last' % maildir, 'r') as fp: last_msg = int(fp.read()) mdir = mailbox.Maildir(maildir) db = notmuch.Database(maildir, mode=notmuch.Database.MODE.READ_WRITE) srv = nntplib.NNTP(config.get_nntp_server()) _, _, first, last, _ = srv.group(config.get_nntp_group()) last = int(last) clear = False for msgno in range(last_msg + 1, last + 1): msg = fetch_msg(srv, str(msgno)) filename = maildir + '/new/' + mdir.add(msg) db.begin_atomic() try: msg, status = db.add_message(filename) finally: db.end_atomic() util.replace_file('%s/.last' % maildir, str(msgno)) sys.stdout.write('\rFetching message %4d of %4d... ' % (msgno - last_msg, last - last_msg)) clear = True sys.stdout.flush() if clear: sys.stdout.write('\n') return 0
def setup(args): maildir = config.get_notmuch_dir() git_dir = config.get_git_dir() try: os.makedirs(git_dir.rsplit('/', 1)[0]) except Exception, e: pass
def setup(args): maildir = config.get_notmuch_dir() git_dir = config.get_git_dir() try: os.makedirs(git_dir.rsplit('/', 1)[0]) except Exception, e: pass
def dump_notmuch_query(patches, args): import notmuch sub_series = find_subseries(patches, args) if not sub_series: return def fn(series): return 'id:"%s"' % series['messages'][0]['message-id'] query = ' or '.join(map(fn, sub_series)) db = notmuch.Database(config.get_notmuch_dir()) q = notmuch.Query(db, query) tids = [] for thread in q.search_threads(): tids.append('thread:%s' % thread.get_thread_id()) out(' or '.join(tids))
def dump_notmuch_query(patches, args): import notmuch sub_series = find_subseries(patches, args) if not sub_series: return def fn(series): return 'id:"%s"' % series['messages'][0]['message-id'] query = ' or '.join(map(fn, sub_series)) db = notmuch.Database(config.get_notmuch_dir()) q = notmuch.Query(db, query) tids = [] for thread in q.search_threads(): tids.append('thread:%s' % thread.get_thread_id()) out(' or '.join(tids))
def refresh(args): maildir = config.get_notmuch_dir() with open('%s/.last' % maildir, 'r') as fp: last_msg = int(fp.read()) mdir = mailbox.Maildir(maildir) db = notmuch.Database(maildir, mode=notmuch.Database.MODE.READ_WRITE) srv = nntplib.NNTP(config.get_nntp_server()) _, _, first, last, _ = srv.group(config.get_nntp_group()) last = int(last) clear = False for msgno in range(last_msg + 1, last + 1): msg = fetch_msg(srv, str(msgno)) filename = maildir + '/new/' + mdir.add(msg) db.begin_atomic() try: msg, status = db.add_message(filename) finally: db.end_atomic() util.replace_file('%s/.last' % maildir, str(msgno)) sys.stdout.write('\rFetching message %4d of %4d... ' % (msgno - last_msg, last - last_msg)) clear = True sys.stdout.flush() if clear: sys.stdout.write('\n') return 0