mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add python3 support for byte encoded markers
Python3 unit test complained about find() and byte encoding not working, so since py2 allows byte ops we will do searches that way and hopefully make py 2 and 3 happy.
This commit is contained in:
parent
09048139c7
commit
3a7cc44ade
1 changed files with 3 additions and 2 deletions
|
@ -421,6 +421,7 @@ def _run(cmd,
|
|||
# There must be a better way to do this.
|
||||
import uuid
|
||||
marker = '<<<' + str(uuid.uuid4()) + '>>>'
|
||||
marker_b = marker.encode(__salt_system_encoding__)
|
||||
py_code = (
|
||||
'import sys, os, itertools; '
|
||||
'sys.stdout.write(\"' + marker + '\\n\"); '
|
||||
|
@ -448,7 +449,7 @@ def _run(cmd,
|
|||
env_encoded_err = env_encoded[1]
|
||||
env_encoded = env_encoded[0]
|
||||
env_encoded_org = env_encoded
|
||||
env_mark = env_encoded.find(marker + '\n')
|
||||
env_mark = env_encoded.find(marker_b + b'\n')
|
||||
if env_mark < 0:
|
||||
raise CommandExecutionError(
|
||||
'Environment could not be retrieved for User \'{0}\':'
|
||||
|
@ -460,7 +461,7 @@ def _run(cmd,
|
|||
)
|
||||
# strip first marker line plus newline
|
||||
env_encoded = env_encoded[env_mark + len(marker) + 1:]
|
||||
env_mark = env_encoded.find('\n' + marker + '\n')
|
||||
env_mark = env_encoded.find(b'\n' + marker_b + b'\n')
|
||||
if env_mark < 0:
|
||||
raise CommandExecutionError(
|
||||
'Environment could not be retrieved for User \'{0}\':'
|
||||
|
|
Loading…
Add table
Reference in a new issue