mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
networks: Handle unavailability of device
This commit is contained in:
parent
8228440319
commit
96b98fae9f
@ -79,15 +79,13 @@ def show(request, uuid):
|
|||||||
active_connection = None
|
active_connection = None
|
||||||
|
|
||||||
# Device status
|
# Device status
|
||||||
|
device = None
|
||||||
if active_connection and active_connection.get_devices():
|
if active_connection and active_connection.get_devices():
|
||||||
device = active_connection.get_devices()[0]
|
device = active_connection.get_devices()[0]
|
||||||
else:
|
else:
|
||||||
interface_name = connection_status['interface_name']
|
interface_name = connection_status['interface_name']
|
||||||
if interface_name:
|
if interface_name:
|
||||||
device = network.get_device_by_interface_name(interface_name)
|
device = network.get_device_by_interface_name(interface_name)
|
||||||
else:
|
|
||||||
# TODO: What to do in this situation?
|
|
||||||
raise RuntimeError('Could not get device status')
|
|
||||||
|
|
||||||
device_status = network.get_status_from_device(device)
|
device_status = network.get_status_from_device(device)
|
||||||
|
|
||||||
|
|||||||
@ -74,36 +74,38 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>Device</h3>
|
{% if device %}
|
||||||
|
<h3>Device</h3>
|
||||||
|
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<div class="list-group-item">
|
|
||||||
State
|
|
||||||
<span class="pull-right">{{ device.state }}</span>
|
|
||||||
</div>
|
|
||||||
{% if device.state_reason != 'none' %}
|
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
State reason
|
State
|
||||||
<span class="pull-right">{{ device.state_reason }}</span>
|
<span class="pull-right">{{ device.state }}</span>
|
||||||
|
</div>
|
||||||
|
{% if device.state_reason != 'none' %}
|
||||||
|
<div class="list-group-item">
|
||||||
|
State reason
|
||||||
|
<span class="pull-right">{{ device.state_reason }}</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="list-group-item">
|
||||||
|
Type
|
||||||
|
<span class="pull-right">{{ device.type }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="list-group-item">
|
||||||
|
MAC address
|
||||||
|
<span class="pull-right">{{ device.hw_address }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="list-group-item">
|
||||||
|
Interface
|
||||||
|
<span class="pull-right">{{ device.interface_name }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="list-group-item">
|
||||||
|
Description
|
||||||
|
<span class="pull-right">{{ device.description }}</span>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
<div class="list-group-item">
|
|
||||||
Type
|
|
||||||
<span class="pull-right">{{ device.type }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="list-group-item">
|
{% endif %}
|
||||||
MAC address
|
|
||||||
<span class="pull-right">{{ device.hw_address }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="list-group-item">
|
|
||||||
Interface
|
|
||||||
<span class="pull-right">{{ device.interface_name }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="list-group-item">
|
|
||||||
Description
|
|
||||||
<span class="pull-right">{{ device.description }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3>Physical Link</h3>
|
<h3>Physical Link</h3>
|
||||||
|
|
||||||
@ -130,14 +132,16 @@
|
|||||||
SSID
|
SSID
|
||||||
<span class="pull-right">{{ connection.wireless.ssid }}</span>
|
<span class="pull-right">{{ connection.wireless.ssid }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="list-group-item">
|
{% if device %}
|
||||||
Speed
|
<div class="list-group-item">
|
||||||
<span class="pull-right">{{ device.wireless.bitrate }} Mbit/s</span>
|
Speed
|
||||||
</div>
|
<span class="pull-right">{{ device.wireless.bitrate }} Mbit/s</span>
|
||||||
<div class="list-group-item">
|
</div>
|
||||||
Mode
|
<div class="list-group-item">
|
||||||
<span class="pull-right">{{ device.wireless.mode }}</span>
|
Mode
|
||||||
</div>
|
<span class="pull-right">{{ device.wireless.mode }}</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% if access_point.channel %}
|
{% if access_point.channel %}
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
Signal strength
|
Signal strength
|
||||||
|
|||||||
@ -161,6 +161,9 @@ def get_status_from_wifi_access_point(device, ssid):
|
|||||||
"""Return the current status of an access point."""
|
"""Return the current status of an access point."""
|
||||||
status = {}
|
status = {}
|
||||||
|
|
||||||
|
if not ssid or not device:
|
||||||
|
return status
|
||||||
|
|
||||||
for access_point in device.get_access_points():
|
for access_point in device.get_access_points():
|
||||||
if access_point.get_ssid().get_data() == ssid:
|
if access_point.get_ssid().get_data() == ssid:
|
||||||
status['strength'] = access_point.get_strength()
|
status['strength'] = access_point.get_strength()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user