Skip to content

Commit

Permalink
update doc for #1830 (net_if_stats() isup check if NIC is running)
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Sep 21, 2020
1 parent 1d5073a commit ba0c0ab
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
4 changes: 3 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ XXXX-XX-XX

**Enhancements**

- 893_: implement Process.environ() on BSD family. (patch by Armin Gruner)
- 893_: implement `Process.environ()` on BSD family. (patch by Armin Gruner)
- 1830_: [UNIX] `net_if_stats()`'s `isup` also checks whether the NIC is
running (meaning Wi-Fi or ethernet cable is connected).

5.7.2
=====
Expand Down
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ Network
system as a dictionary whose keys are the NIC names and value is a named tuple
with the following fields:

- **isup**: a bool indicating whether the NIC is up and running.
- **isup**: a bool indicating whether the NIC is up and running (meaning
ethernet cable or Wi-Fi is connected).
- **duplex**: the duplex communication type;
it can be either :const:`NIC_DUPLEX_FULL`, :const:`NIC_DUPLEX_HALF` or
:const:`NIC_DUPLEX_UNKNOWN`.
Expand All @@ -706,6 +707,7 @@ Network

.. versionadded:: 3.0.0

.. versionchanged:: 5.7.3 `isup` on UNIX also checks whether the NIC is running.

Sensors
-------
Expand Down
2 changes: 1 addition & 1 deletion psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@

__all__.extend(_psplatform.__extra__all__)
__author__ = "Giampaolo Rodola'"
__version__ = "5.7.2"
__version__ = "5.7.3"
version_info = tuple([int(num) for num in __version__.split('.')])

_timer = getattr(time, 'monotonic', time.time)
Expand Down
2 changes: 1 addition & 1 deletion psutil/_psbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def net_if_stats():
for name in names:
try:
mtu = cext_posix.net_if_mtu(name)
isup = cext_posix.net_if_flags(name)
isup = cext_posix.net_if_is_running(name)
duplex, speed = cext_posix.net_if_duplex_speed(name)
except OSError as err:
# https://github.com/giampaolo/psutil/issues/1279
Expand Down
2 changes: 1 addition & 1 deletion psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ def net_if_stats():
for name in names:
try:
mtu = cext_posix.net_if_mtu(name)
isup = cext_posix.net_if_flags(name)
isup = cext_posix.net_if_is_running(name)
duplex, speed = cext.net_if_duplex_speed(name)
except OSError as err:
# https://github.com/giampaolo/psutil/issues/1279
Expand Down
2 changes: 1 addition & 1 deletion psutil/_psosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def net_if_stats():
for name in names:
try:
mtu = cext_posix.net_if_mtu(name)
isup = cext_posix.net_if_flags(name)
isup = cext_posix.net_if_is_running(name)
duplex, speed = cext_posix.net_if_duplex_speed(name)
except OSError as err:
# https://github.com/giampaolo/psutil/issues/1279
Expand Down
6 changes: 3 additions & 3 deletions psutil/_psutil_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ psutil_net_if_mtu(PyObject *self, PyObject *args) {
* http://www.i-scream.org/libstatgrab/
*/
static PyObject *
psutil_net_if_flags(PyObject *self, PyObject *args) {
psutil_net_if_is_running(PyObject *self, PyObject *args) {
char *nic_name;
int sock = -1;
int ret;
Expand Down Expand Up @@ -621,8 +621,8 @@ static PyMethodDef mod_methods[] = {
"Retrieve NICs information"},
{"net_if_mtu", psutil_net_if_mtu, METH_VARARGS,
"Retrieve NIC MTU"},
{"net_if_flags", psutil_net_if_flags, METH_VARARGS,
"Retrieve NIC flags"},
{"net_if_is_running", psutil_net_if_is_running, METH_VARARGS,
"Return True if the NIC is running."},
#if defined(PSUTIL_BSD) || defined(PSUTIL_OSX)
{"net_if_duplex_speed", psutil_net_if_duplex_speed, METH_VARARGS,
"Return NIC stats."},
Expand Down

0 comments on commit ba0c0ab

Please sign in to comment.