Skip to content

Commit

Permalink
Drop six use for binary/string type identification
Browse files Browse the repository at this point in the history
With Python 3.6 being the minimum supported version, dropping six here
and utilising 3.x type identifiers.
  • Loading branch information
Stealthii committed Oct 18, 2023
1 parent 4d58a17 commit a5c2f73
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions contrib/runners/winrm_runner/winrm_runner/winrm_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import base64
import os
import re
import six
import time

from base64 import b64encode
Expand Down Expand Up @@ -257,10 +256,10 @@ def _translate_response(self, response):
}

# Ensure stdout and stderr is always a string
if isinstance(result["stdout"], six.binary_type):
if isinstance(result["stdout"], bytes):
result["stdout"] = result["stdout"].decode("utf-8")

if isinstance(result["stderr"], six.binary_type):
if isinstance(result["stderr"], bytes):
result["stderr"] = result["stderr"].decode("utf-8")

# automatically convert result stdout/stderr from JSON strings to
Expand Down Expand Up @@ -316,7 +315,7 @@ def _upload(self, src_path_or_data, dst_path):

def _upload_chunk(self, dst_path, src_data):
# adapted from https://github.com/diyan/pywinrm/issues/18
if not isinstance(src_data, six.binary_type):
if not isinstance(src_data, bytes):
src_data = src_data.encode("utf-8")

ps = """$filePath = "{dst_path}"
Expand Down Expand Up @@ -446,7 +445,7 @@ def _param_to_ps(self, param):
ps_str = ""
if param is None:
ps_str = "$null"
elif isinstance(param, six.string_types):
elif isinstance(param, str):
ps_str = '"' + self._multireplace(param, PS_ESCAPE_SEQUENCES) + '"'
elif isinstance(param, bool):
ps_str = "$true" if param else "$false"
Expand All @@ -459,7 +458,7 @@ def _param_to_ps(self, param):
ps_str += "; ".join(
[
(self._param_to_ps(k) + " = " + self._param_to_ps(v))
for k, v in six.iteritems(param)
for k, v in param.items()
]
)
ps_str += "}"
Expand All @@ -473,7 +472,7 @@ def _transform_params_to_ps(self, positional_args, named_args):
positional_args[i] = self._param_to_ps(arg)

if named_args:
for key, value in six.iteritems(named_args):
for key, value in named_args.items():
named_args[key] = self._param_to_ps(value)

return positional_args, named_args
Expand All @@ -487,7 +486,7 @@ def create_ps_params_string(self, positional_args, named_args):
ps_params_str = ""
if named_args:
ps_params_str += " ".join(
[(k + " " + v) for k, v in six.iteritems(named_args)]
[(k + " " + v) for k, v in named_args.items()]
)
ps_params_str += " "
if positional_args:
Expand Down

0 comments on commit a5c2f73

Please sign in to comment.