Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_encoding: if python3 not found, failback #653

Conversation

guillaumewatteeux
Copy link

When i wants to use ansible backend on windows host, i have a problem with ascii decode

Use ansible.windows.win_service_info to retrieve all services

def test_services(host):
    res = host.ansible(
        "ansible.windows.win_service_info", "", check=False
    )
    for service in res['services']:
        print(f"DEBUG {service['name']}")

result:

self = <encodings.ascii.IncrementalDecoder object at 0x7f695f40dfa0>
input = b'{"changed": false, "exists": true, "services": [{"checkpoint": 0, "controls_accepted": [], "dependencies": [], "depe...4d", "type": "network_endpoint"}], "username": "NT AUTHORITY\\\\SYSTEM", "wait_hint_ms": 0, "win32_exit_code": 1077}]}'
final = True

    def decode(self, input, final=False):
>       return codecs.ascii_decode(input, self.errors)[0]
E       UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 72968: ordinal not in range(128)

On windows, a service "Function Discovery Provider Host" contains a description with Web Services – Discovery (character 'En Dash', U+2013)
a 'En dash' character in service description ....

I'm using Ansible backend on windows, python don't install on it.

I add a try/except on backend/base.py to failback on locale.getpreferredencoding()

@philpep
Copy link
Contributor

philpep commented Nov 5, 2022

Hi, windows is not fully supported. I think the bug must be addressed at a upper level. Maybe rather open an issue for this particular bug.

@philpep philpep closed this Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants