X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=devel%2Fnmbug%2Fnmbug-status;h=a7a391da43a38980b03c6c44d37cec8eb689be79;hp=6525176478d2155d274f63184d3c3057b8ace25e;hb=fd29d3f;hpb=ee6b5c372f724d2352d155736b81d2d46130c929 diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status index 65251764..a7a391da 100755 --- a/devel/nmbug/nmbug-status +++ b/devel/nmbug/nmbug-status @@ -8,8 +8,10 @@ from __future__ import print_function +import codecs import datetime import email.utils +import locale import urllib import json import argparse @@ -17,6 +19,10 @@ import os import sys import subprocess + +_ENCODING = locale.getpreferredencoding() or sys.getdefaultencoding() + + # parse command line arguments parser = argparse.ArgumentParser() @@ -37,15 +43,16 @@ else: nmbhome = os.getenv('NMBGIT', os.path.expanduser('~/.nmbug')) # read only the first line from the pipe - sha1 = subprocess.Popen(['git', '--git-dir', nmbhome, - 'show-ref', '-s', 'config'], - stdout=subprocess.PIPE).stdout.readline() - - sha1 = sha1.rstrip() - - fp = subprocess.Popen(['git', '--git-dir', nmbhome, - 'cat-file', 'blob', sha1+':status-config.json'], - stdout=subprocess.PIPE).stdout + sha1_bytes = subprocess.Popen( + ['git', '--git-dir', nmbhome, 'show-ref', '-s', 'config'], + stdout=subprocess.PIPE).stdout.readline() + sha1 = sha1_bytes.decode(_ENCODING).rstrip() + + fp_byte_stream = subprocess.Popen( + ['git', '--git-dir', nmbhome, 'cat-file', 'blob', + sha1+':status-config.json'], + stdout=subprocess.PIPE).stdout + fp = codecs.getreader(encoding=_ENCODING)(stream=fp_byte_stream) config = json.load(fp)