mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +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
|
||||
|
||||
# Device status
|
||||
device = None
|
||||
if active_connection and active_connection.get_devices():
|
||||
device = active_connection.get_devices()[0]
|
||||
else:
|
||||
interface_name = connection_status['interface_name']
|
||||
if 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)
|
||||
|
||||
|
||||
@ -74,36 +74,38 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Device</h3>
|
||||
{% if device %}
|
||||
<h3>Device</h3>
|
||||
|
||||
<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">
|
||||
<div class="list-group-item">
|
||||
State reason
|
||||
<span class="pull-right">{{ device.state_reason }}</span>
|
||||
State
|
||||
<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>
|
||||
{% 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 %}
|
||||
|
||||
<h3>Physical Link</h3>
|
||||
|
||||
@ -130,14 +132,16 @@
|
||||
SSID
|
||||
<span class="pull-right">{{ connection.wireless.ssid }}</span>
|
||||
</div>
|
||||
<div class="list-group-item">
|
||||
Speed
|
||||
<span class="pull-right">{{ device.wireless.bitrate }} Mbit/s</span>
|
||||
</div>
|
||||
<div class="list-group-item">
|
||||
Mode
|
||||
<span class="pull-right">{{ device.wireless.mode }}</span>
|
||||
</div>
|
||||
{% if device %}
|
||||
<div class="list-group-item">
|
||||
Speed
|
||||
<span class="pull-right">{{ device.wireless.bitrate }} Mbit/s</span>
|
||||
</div>
|
||||
<div class="list-group-item">
|
||||
Mode
|
||||
<span class="pull-right">{{ device.wireless.mode }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if access_point.channel %}
|
||||
<div class="list-group-item">
|
||||
Signal strength
|
||||
|
||||
@ -161,6 +161,9 @@ def get_status_from_wifi_access_point(device, ssid):
|
||||
"""Return the current status of an access point."""
|
||||
status = {}
|
||||
|
||||
if not ssid or not device:
|
||||
return status
|
||||
|
||||
for access_point in device.get_access_points():
|
||||
if access_point.get_ssid().get_data() == ssid:
|
||||
status['strength'] = access_point.get_strength()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user