# HG changeset patch # User Peter Sanchez # Date 1721325613 21600 # Thu Jul 18 12:00:13 2024 -0600 # Node ID dc4fe72536ad790021d4660b2a8d73d4a1f1a923 # Parent bc05a631589a36d07e66de7a60065979151ad6ea Update mutt-notmuch-py to be py3 compatible diff --git a/bin/mutt-notmuch-py b/bin/mutt-notmuch-py --- a/bin/mutt-notmuch-py +++ b/bin/mutt-notmuch-py @@ -1,4 +1,4 @@ -#!/usr/local/bin/python +#!/usr/bin/python3 """ mutt-notmuch-py @@ -21,15 +21,14 @@ (c) 2012 - Honza Pokorny Licensed under BSD """ -import hashlib, sys -from commands import getoutput +import hashlib, sys, subprocess from mailbox import Maildir from optparse import OptionParser def digest(filename): with open(filename) as f: - return hashlib.sha1(f.read()).hexdigest() + return hashlib.sha1(f.read().encode()).hexdigest() def pick_all_mail(messages): @@ -44,11 +43,12 @@ def command(cmd): - return getoutput(cmd) + cmds = cmd.split() + return subprocess.run(cmds, capture_output=True) def main(dest_box): - query = raw_input('Query: ') + query = input('Query: ') command('mkdir -p %s' % dest_box) command('mkdir -p %s/cur' % dest_box) @@ -56,7 +56,7 @@ empty_dir(dest_box) - files = command('notmuch search --output=files %s' % query).split('\n') + files = command('notmuch search --output=files %s' % query).stdout.decode().split('\n') files = filter(None, files) data = {}