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

Issue with wmic and character encoding #10

Open
jameswpm opened this issue Feb 28, 2018 · 0 comments
Open

Issue with wmic and character encoding #10

jameswpm opened this issue Feb 28, 2018 · 0 comments

Comments

@jameswpm
Copy link

OS: Debian 8.10
Python 2.7.9
wmic downloaded from here with all patches applied

Repeatable: Always

Problem description:

Apparently, the wmic returns some results with encoding problems when the windows info have some non-Unicode symbols. I tried to find any flag or option within this python wrapper, but apparently, we don't have any. I'm opening this issue for two reasons:

  1. Ensure that the wrapper does not have any flag or option to work with UTF-8 encoding;
  2. Leave the suggestion for a possible improvement, since this problem can affect many users.

Steps to repeat:

  1. Install the wrapper following the README.md;

  2. Create an user 'james' at the windows machine with the full name set to "Jamés Júnior" (or anything similar);

  3. Create a python script like below with a query to get users info;

     #!/usr/bin/python
    
     import wmi_client_wrapper as wmi
    
     wmic = wmi.WmiClientWrapper(
         username="user",
         password="pass",
         host="1.1.1.1",
         delimiter="|"
     )
    
     output = wmic.query("SELECT * FROM Win32_NetworkLoginProfile")
     print(output)
    
  4. Run it with python script.py.

Expected Results:
A JSON String with all users infos.

Actual Results:
A JSON with the expected result is actually returned, but that users with non-Unicode characters are returned with strange (and impossible to detect) character encoding. For example, the user james is returned with full name as:

    ...'AccountExpires': None, 'FullName': 'Jam\xc3\x9as J\xc2\xb7nior'}]

Just for information, in the UTF-8 char table the symbols \xc3\x9a and \xc2\xb7 are, respectively, "Ú" and "·".

Note:

Since I believe that this issue is a wmic issue more than a wrapper issue, I also opened an Stack Overflow thread independent of the python part, but this issue is, besides an question, an improvement suggestion.

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

No branches or pull requests

1 participant