Make get_email() work with python3
If you try to build the docs with python3 you'll see something ending with: ValueError: Couldn't find gerrit account with 'b'dmccowan@cisco.com'' This is because the default encoding from subprocess.Popen() under python3 is bytes() which then fails to work with the gerrit API. Check we have a text_type and decode() if needed. Change-Id: Iccbc891a33d15ef82ddbc913549e64547a967195
This commit is contained in:
parent
e9d300dcf3
commit
c217a1db8b
@ -21,6 +21,7 @@ import pickle
|
||||
import pytz
|
||||
import re
|
||||
import requests
|
||||
import six
|
||||
import subprocess
|
||||
import time
|
||||
import yaml
|
||||
@ -77,7 +78,12 @@ def gerrit_query(url):
|
||||
def get_email(filepath):
|
||||
cmd = ["git", "log", "--follow", "--format=%aE", filepath]
|
||||
git = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
return git.stdout.readlines()[-1][:-1]
|
||||
email = git.stdout.readlines()[-1][:-1]
|
||||
# Force to text_type in py2 or py3
|
||||
if isinstance(email, six.text_type):
|
||||
return email
|
||||
else:
|
||||
return email.decode('utf-8')
|
||||
|
||||
|
||||
def get_gerrit_account(email):
|
||||
|
Loading…
Reference in New Issue
Block a user