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

Not listing NICs with unicode name in windows. #446

Closed
giampaolo opened this issue May 23, 2014 · 12 comments
Closed

Not listing NICs with unicode name in windows. #446

giampaolo opened this issue May 23, 2014 · 12 comments

Comments

@giampaolo
Copy link
Owner

From lukasgu...@gmail.com on November 28, 2013 19:12:35

What steps will reproduce the problem?  
1. Rename any NIC's connection to something with unicode characters, like 
"Połączenie lokalne" - default name in Polish version of Windows
2. Simply try get stats 

What is the expected output?  
Stats for every NIC 

What do you see instead?  
Stats only for NICs named without any unicode characters 

What version of psutil are you using? What Python version?  
Problem occurs both on Python 2.3.7 and 3.3, x86 

On what operating system? Is it 32bit or 64bit version?  
Windows 7 Pro x64 SP1 Please provide any additional information below.

Original issue: http://code.google.com/p/psutil/issues/detail?id=446

@giampaolo
Copy link
Owner Author

From g.rodola on December 02, 2013 11:42:47

I tried to look into this but so far I wasn't able to find any solution as the 
way we're retrieving the NIC name is the one recommended by the official 
Windows documentation.

For posterity, problem is here: 
https://code.google.com/p/psutil/source/browse/psutil/_psutil_mswindows.c?name=release-1.2.1#2258

@giampaolo
Copy link
Owner Author

From g.rodola on December 02, 2013 11:44:46

Also, another note: on my Windows 7 box the NIC gets listed but its name is 
truncated after encountering the first unicode character (whereas you state it 
is not listed at all - are you sure about that?).

Labels: -Priority-High Priority-Medium OpSys-Windows

@giampaolo
Copy link
Owner Author

From lukasgu...@gmail.com on December 07, 2013 06:46:15

Yup, I'm sure. Maybe try re-encode the string or add an option to strip unicode 
characters?
In my case NICs with unicode characters simply doesn't appear in the returned 
list, they aren't counted into overall stats too.

@giampaolo
Copy link
Owner Author

From g.rodola on December 07, 2013 06:47:48

Does ipconfig /all show the NIC?

@giampaolo
Copy link
Owner Author

From lukasgu...@gmail.com on December 07, 2013 06:49:28

Yes, of course.

@giampaolo
Copy link
Owner Author

From lukasgu...@gmail.com on January 31, 2014 14:59:36

Any progress?

@giampaolo
Copy link
Owner Author

From g.rodola on January 31, 2014 17:24:52

No, sorry. I'm also pretty swamped lately because of a new job so I won't have 
time to dedicate to this issue (and psutil in general to be entirely honest).

@giampaolo
Copy link
Owner Author

From g.rodola on March 31, 2014 09:55:14

Issue 491 has been merged into this issue.

@giampaolo
Copy link
Owner Author

From szigeti....@gmail.com on April 17, 2014 05:59:23

The problem is here: 
https://code.google.com/p/psutil/source/browse/psutil/_psutil_mswindows.c?name=release-1.2.1#2260
 The Py_BuildValue able to decode only the UNICODE characters.
I made the following path to replace these characters with "_".

    while (pCurrAddresses) {
        py_nic_name = NULL;
        py_nic_info = NULL;
>   int i;
        ...
        sprintf(ifname, "%ws", pCurrAddresses->FriendlyName);
>   for (i=0; i<100; i++) {
>     if ( *(ifname+i) < 0 || *(ifname+i) > 256 ) {
>        // Replace the NON UNICODE character
>        *(ifname+i)='_';
>     }
>     if (*(ifname+i) == '\0') {
>       // end of friendly name
>       break;
>     }
>   }
        py_nic_name = Py_BuildValue("s", ifname);

@g.rodola: can you put this patch into the next release?

@giampaolo
Copy link
Owner Author

From g.rodola on April 29, 2014 10:40:37

Issue 500 has been merged into this issue.

@giampaolo
Copy link
Owner Author

From g.rodola on April 29, 2014 12:16:46

Despite this is a dirty hack I couldn't find any better solution so I committed 
your patch as of revision f5bbb4efc031 .
Thanks.

Status: FixedInHG
Labels: Python-3.X Milestone-2.1.1

@giampaolo
Copy link
Owner Author

From g.rodola on May 13, 2014 07:42:26

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant