nmcli 1.2.0__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {nmcli-1.2.0 → nmcli-1.4.0}/PKG-INFO +11 -2
  2. {nmcli-1.2.0 → nmcli-1.4.0}/README.md +10 -1
  3. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/_device.py +4 -2
  4. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/data/device.py +1 -1
  5. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/data/general.py +34 -3
  6. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/dummy/_device.py +3 -4
  7. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli.egg-info/PKG-INFO +11 -2
  8. {nmcli-1.2.0 → nmcli-1.4.0}/setup.py +1 -1
  9. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/__init__.py +0 -0
  10. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/_connection.py +0 -0
  11. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/_const.py +0 -0
  12. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/_exception.py +0 -0
  13. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/_general.py +0 -0
  14. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/_helper.py +0 -0
  15. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/_networking.py +0 -0
  16. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/_radio.py +0 -0
  17. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/_system.py +0 -0
  18. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/data/__init__.py +0 -0
  19. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/data/connection.py +0 -0
  20. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/data/hotspot.py +0 -0
  21. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/data/radio.py +0 -0
  22. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/dummy/__init__.py +0 -0
  23. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/dummy/_connection.py +0 -0
  24. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/dummy/_general.py +0 -0
  25. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/dummy/_networking.py +0 -0
  26. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/dummy/_radio.py +0 -0
  27. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli/py.typed +0 -0
  28. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli.egg-info/SOURCES.txt +0 -0
  29. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli.egg-info/dependency_links.txt +0 -0
  30. {nmcli-1.2.0 → nmcli-1.4.0}/nmcli.egg-info/top_level.txt +0 -0
  31. {nmcli-1.2.0 → nmcli-1.4.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nmcli
3
- Version: 1.2.0
3
+ Version: 1.4.0
4
4
  Summary: A python wrapper library for the network-manager cli client
5
5
  Home-page: https://github.com/ushiboy/nmcli
6
6
  Author: ushiboy
@@ -256,7 +256,7 @@ Description: nmcli
256
256
  List available Wi-Fi access points.
257
257
 
258
258
  ```
259
- nmcli.device.wifi(ifname: str = None) -> List[DeviceWifi]
259
+ nmcli.device.wifi(ifname: str = None, rescan: bool = None) -> List[DeviceWifi]
260
260
  ```
261
261
 
262
262
  #### nmcli.device.wifi_connect
@@ -466,6 +466,15 @@ Description: nmcli
466
466
 
467
467
  ## Change Log
468
468
 
469
+ ### 1.4.0
470
+
471
+ - Supported unsupported cases of `DeviceWifi.parse`.
472
+ - Fixed the problem that `nmcli.general` does not work on nmcli client after version 1.48.x.
473
+
474
+ ### 1.3.0
475
+
476
+ - Added rescan parameter to `nmcli.device.wifi`.
477
+
469
478
  ### 1.2.0
470
479
 
471
480
  - Added support for encodings other than UTF-8.
@@ -249,7 +249,7 @@ nmcli.device.delete(ifname: str, wait: int = None) -> None
249
249
  List available Wi-Fi access points.
250
250
 
251
251
  ```
252
- nmcli.device.wifi(ifname: str = None) -> List[DeviceWifi]
252
+ nmcli.device.wifi(ifname: str = None, rescan: bool = None) -> List[DeviceWifi]
253
253
  ```
254
254
 
255
255
  #### nmcli.device.wifi_connect
@@ -459,6 +459,15 @@ nmcli.set_lang(lang: str) -> None
459
459
 
460
460
  ## Change Log
461
461
 
462
+ ### 1.4.0
463
+
464
+ - Supported unsupported cases of `DeviceWifi.parse`.
465
+ - Fixed the problem that `nmcli.general` does not work on nmcli client after version 1.48.x.
466
+
467
+ ### 1.3.0
468
+
469
+ - Added rescan parameter to `nmcli.device.wifi`.
470
+
462
471
  ### 1.2.0
463
472
 
464
473
  - Added support for encodings other than UTF-8.
@@ -60,7 +60,7 @@ class DeviceControlInterface:
60
60
  def delete(self, ifname: str, wait: int = None) -> None:
61
61
  raise NotImplementedError
62
62
 
63
- def wifi(self, ifname: str = None) -> List[DeviceWifi]:
63
+ def wifi(self, ifname: str = None, rescan: bool = None) -> List[DeviceWifi]:
64
64
  raise NotImplementedError
65
65
 
66
66
  def wifi_connect(self,
@@ -145,11 +145,13 @@ class DeviceControl(DeviceControlInterface):
145
145
  wait) + ['device', 'delete', ifname]
146
146
  self._syscmd.nmcli(cmd)
147
147
 
148
- def wifi(self, ifname: str = None) -> List[DeviceWifi]:
148
+ def wifi(self, ifname: str = None, rescan: bool = None) -> List[DeviceWifi]:
149
149
  cmd = ['-t', '-f', 'IN-USE,SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,SECURITY',
150
150
  'device', 'wifi', 'list']
151
151
  if ifname is not None:
152
152
  cmd += ['ifname', ifname]
153
+ if rescan is not None:
154
+ cmd += ['--rescan', 'yes' if rescan else 'no']
153
155
  r = self._syscmd.nmcli(cmd)
154
156
  results = []
155
157
  rows = r.split('\n')
@@ -64,7 +64,7 @@ class DeviceWifi:
64
64
  t = text.replace("\\:", "\uFFFE").replace(
65
65
  ":", "\uFFFF").replace("\uFFFE", ":")
66
66
  m = re.search(
67
- r'^(\*|\s)\uFFFF(.*)\uFFFF(.*)\uFFFF(.*)\uFFFF(\d+)\uFFFF(\d+)\sMHz\uFFFF(\d+)\sMbit\/s\uFFFF(\d+)\uFFFF(.*)$', t)
67
+ r'^(\*|\s)\uFFFF(.*)\uFFFF(.*)\uFFFF(.*)\uFFFF(\d+)\uFFFF(\d+)\sMHz\uFFFF(\d+)\s(?:Mb|Mbit)\/s\uFFFF(\d+)\uFFFF(.*)$', t)
68
68
  if m:
69
69
  in_use, ssid, bssid, mode, chan, freq, rate, signal, security = m.groups()
70
70
  return DeviceWifi(in_use == '*', ssid, bssid, mode,
@@ -25,12 +25,43 @@ class General:
25
25
  'wwan': self.wwan
26
26
  }
27
27
 
28
+ # case 1:
29
+ # STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN METERED
30
+ # connected full enabled enabled missing enabled no (guessed)
31
+ #
32
+ # case 2:
33
+ # unknown none enabled enabled enabled disabled
34
+ #
35
+ # case 3:
36
+ # connected (local only) full disabled enabled enabled enabled
37
+ #
38
+ # see: https://regex101.com/r/zW1hHE/1
39
+
28
40
  @classmethod
29
41
  def parse(cls, text: str) -> General:
30
- m = re.search(
31
- r'^([\S\s]+)\s{2}(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*', text)
42
+ pattern = (
43
+ r'^'
44
+ + r'(?P<state>.+)'
45
+ + r' '
46
+ + r'(?P<connectivity>\S+)'
47
+ + r'\s+'
48
+ + r'(?P<wifi_hw>\S+)'
49
+ + r' '
50
+ + r'(?P<wifi>\S+)'
51
+ + r' '
52
+ + r'(?P<wwan_hw>\S+)'
53
+ + r' '
54
+ + r'(?P<wwan>\S+)'
55
+ + r'(?: (?P<metered>.+)?)?'
56
+ + r'$'
57
+ )
58
+
59
+ # The execution result will have a trailing space,
60
+ # so trim it and then match it to the pattern.
61
+ m = re.search(pattern, text.rstrip())
62
+
32
63
  if m:
33
- state, connectivity, wifi_hw, wifi, wwan_hw, wwan = m.groups()
64
+ state, connectivity, wifi_hw, wifi, wwan_hw, wwan, _metered = m.groups()
34
65
  return General(NetworkManagerState(state),
35
66
  NetworkConnectivity(connectivity),
36
67
  wifi_hw == 'enabled',
@@ -61,7 +61,7 @@ class DummyDeviceControl(DeviceControlInterface):
61
61
  self._disconnect_args: List[Tuple] = []
62
62
  self._reapply_args: List[str] = []
63
63
  self._delete_args: List[Tuple] = []
64
- self._wifi_args: List[str] = []
64
+ self._wifi_args: List[Tuple] = []
65
65
  self._wifi_connect_args: List[Tuple] = []
66
66
  self._wifi_hotspot_args: List[Tuple] = []
67
67
  self._wifi_rescan_args: List[Tuple] = []
@@ -101,10 +101,9 @@ class DummyDeviceControl(DeviceControlInterface):
101
101
  self._raise_error_if_needed()
102
102
  self._delete_args.append((ifname, wait))
103
103
 
104
- def wifi(self, ifname: str = None) -> List[DeviceWifi]:
104
+ def wifi(self, ifname: str = None, rescan: bool = None) -> List[DeviceWifi]:
105
105
  self._raise_error_if_needed()
106
- if ifname is not None:
107
- self._wifi_args.append(ifname)
106
+ self._wifi_args.append((ifname, rescan))
108
107
  return self._result_wifi
109
108
 
110
109
  def wifi_connect(self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nmcli
3
- Version: 1.2.0
3
+ Version: 1.4.0
4
4
  Summary: A python wrapper library for the network-manager cli client
5
5
  Home-page: https://github.com/ushiboy/nmcli
6
6
  Author: ushiboy
@@ -256,7 +256,7 @@ Description: nmcli
256
256
  List available Wi-Fi access points.
257
257
 
258
258
  ```
259
- nmcli.device.wifi(ifname: str = None) -> List[DeviceWifi]
259
+ nmcli.device.wifi(ifname: str = None, rescan: bool = None) -> List[DeviceWifi]
260
260
  ```
261
261
 
262
262
  #### nmcli.device.wifi_connect
@@ -466,6 +466,15 @@ Description: nmcli
466
466
 
467
467
  ## Change Log
468
468
 
469
+ ### 1.4.0
470
+
471
+ - Supported unsupported cases of `DeviceWifi.parse`.
472
+ - Fixed the problem that `nmcli.general` does not work on nmcli client after version 1.48.x.
473
+
474
+ ### 1.3.0
475
+
476
+ - Added rescan parameter to `nmcli.device.wifi`.
477
+
469
478
  ### 1.2.0
470
479
 
471
480
  - Added support for encodings other than UTF-8.
@@ -13,7 +13,7 @@ with open('README.md', 'r') as f:
13
13
 
14
14
  setup(
15
15
  name='nmcli',
16
- version='1.2.0',
16
+ version='1.4.0',
17
17
  author='ushiboy',
18
18
  license='MIT',
19
19
  license_files = ('LICENSE.txt',),
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes