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

force command to use C locale #47

Merged
merged 1 commit into from
Feb 12, 2020
Merged

force command to use C locale #47

merged 1 commit into from
Feb 12, 2020

Conversation

fdellwing
Copy link
Contributor

I have not tested this on windows, maybe there needs to be an additional check for that!

So the problem I'm trying to fix here, is that if you system uses a non English locale the LinuxParser will not give the expected results because the regex does not match anymore:

# echo $LANG
de_DE.UTF-8
# ifconfig brlan
brlan     Link encap:Ethernet  Hardware Adresse 00:50:56:a1:45:0a  
          inet Adresse:172.16.10.15  Bcast:172.16.15.255  Maske:255.255.240.0
          inet6-Adresse: fe80::250:56ff:fea1:450a/64 Gültigkeitsbereich:Verbindung
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metrik:1
          RX packets:33399 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10607 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:1000 
          RX bytes:1732712 (1.6 MiB)  TX bytes:876186 (855.6 KiB)
# LANG=C ifconfig brlan
brlan     Link encap:Ethernet  HWaddr 00:50:56:a1:45:0a  
          inet addr:172.16.10.15  Bcast:172.16.15.255  Mask:255.255.240.0
          inet6 addr: fe80::250:56ff:fea1:450a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:33409 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10612 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1733232 (1.6 MiB)  TX bytes:876616 (856.0 KiB)

Without this change:

Python 3.7.6 (default, Feb  5 2020, 15:49:29) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ifcfg
>>> ifcfg.interfaces().get("brlan")
{'inet': None, 'inet4': [], 'ether': None, 'inet6': [], 'netmask': None, 'device': 'brlan', 'broadcast': '172.16.15.255', 'mtu': '1500', 'rxbytes': '1734110', 'txbytes': '877304'}
>>>

With this change:

Python 3.7.6 (default, Feb  5 2020, 15:49:29) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ifcfg
>>> ifcfg.interfaces().get("brlan")
{'inet': '172.16.10.15', 'inet4': ['172.16.10.15'], 'ether': '00:50:56:a1:45:0a', 'inet6': ['add', 'fe80::250:56ff:fea1:450a'], 'netmask': '255.255.240.0', 'device': 'brlan', 'broadcast': '172.16.15.255', 'mtu': '1500', 'rxbytes': '1734526', 'txbytes': '877718'}

@codecov-io
Copy link

Codecov Report

Merging #47 into master will increase coverage by 0.13%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #47      +/-   ##
==========================================
+ Coverage   83.33%   83.47%   +0.13%     
==========================================
  Files           4        4              
  Lines         240      242       +2     
==========================================
+ Hits          200      202       +2     
  Misses         40       40
Impacted Files Coverage Δ
src/ifcfg/tools.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0bd672...992cbae. Read the comment docs.

@fdellwing fdellwing requested a review from benjaoming February 10, 2020 10:47
@benjaoming
Copy link
Collaborator

Am really glad that you have looked into this! This seems like an important fix that we should release. Thanks!

@benjaoming benjaoming merged commit fbe913a into ftao:master Feb 12, 2020
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.

3 participants