From d5107fb63a688236c4bd8275cb3884c2a58ec2f6 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Thu, 27 Oct 2016 12:24:07 +0300 Subject: Raise custom exception with ifconfig --- machammer/network.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/machammer/network.py b/machammer/network.py index 17608ce..5f5fb87 100644 --- a/machammer/network.py +++ b/machammer/network.py @@ -32,7 +32,11 @@ def get_wifi_power(): def is_wired(primary=False): """Do we have an "active" Ethernet connection?""" for p in get_ports('Ethernet'): - r = check_output('/sbin/ifconfig', p['interface']) + try: + r = check_output('/sbin/ifconfig', p['interface']) + except Exception as e: + raise Exception('Failed to get interface status: %s' % e) + active = 'status: active' in r return get_primary(p['interface']) if primary else active -- cgit v1.2.3