Skip to content

Commit

Permalink
Update to the environment_{file|loader} feature to fix compatibility …
Browse files Browse the repository at this point in the history
…with python 3.{4,5,6}
  • Loading branch information
wynnw committed Apr 30, 2021
1 parent bf80f2b commit 8f1675a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions supervisor/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1978,11 +1978,17 @@ def load_external_environment_definition_for_config(cls, config):
try:
from subprocess import check_output, CalledProcessError
kwargs = dict(shell=True)
if not PY2:
kwargs['text'] = True
if sys.version_info.major >= 3:
if sys.version_info.minor >= 7:
kwargs['text'] = True
else:
pass # we will decode the bytes returned after reading it for these versions of python

envdata = check_output(config.environment_loader, **kwargs)

if sys.version_info.major >= 3 and sys.version_info.minor < 7:
envdata = envdata.decode('utf8')

except CalledProcessError as e:
raise ProcessException("environment_loader failure with %s: %d, %s" % (config.environment_loader, e.returncode, e.output))

Expand Down

0 comments on commit 8f1675a

Please sign in to comment.