[FIX] hw_drivers: No devices after monitor disconnect
Steps to reproduce: - Start the IoT Box with a monitor plugged in - Unplug the monitor - Restart the Odoo service (i.e. connect the IoT Box to a DB) - No devices are detected The problem came from the fact that `tvservice -l` and `tvservice -n` have different behaviors when a monitor is disconnected: - `tvservice -l` still says that a device is attached - `tvservice -n` cannot detect the name of the device so it logs an error to stderr but still has a return value of 0 so we read an empty string from stdout. The `get_connected_displays` function raised an exception because the format of the returned string was not the one we excepted. The other loops were then not started and no devices at all were detected. closes odoo/odoo#50839 X-original-commit: ab6ec2ab6d30a86f9741da4b1986831772004d91 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com> Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
This commit is contained in:
@@ -342,15 +342,17 @@ class Manager(Thread):
|
||||
x_screen = 0
|
||||
for match in finditer('Display Number (\d), type HDMI (\d)', displays):
|
||||
display_id, hdmi_id = match.groups()
|
||||
display_name = subprocess.check_output(['tvservice', '-nv', display_id]).decode().rstrip().split('=')[1]
|
||||
display_identifier = sub('[^a-zA-Z0-9 ]+', '', display_name).replace(' ', '_') + "_" + str(hdmi_id)
|
||||
iot_device = IoTDevice({
|
||||
'identifier': display_identifier,
|
||||
'name': display_name,
|
||||
'x_screen': str(x_screen),
|
||||
}, 'display')
|
||||
display_devices[display_identifier] = iot_device
|
||||
x_screen += 1
|
||||
tvservice_output = subprocess.check_output(['tvservice', '-nv', display_id]).decode().rstrip()
|
||||
if tvservice_output:
|
||||
display_name = tvservice_output.split('=')[1]
|
||||
display_identifier = sub('[^a-zA-Z0-9 ]+', '', display_name).replace(' ', '_') + "_" + str(hdmi_id)
|
||||
iot_device = IoTDevice({
|
||||
'identifier': display_identifier,
|
||||
'name': display_name,
|
||||
'x_screen': str(x_screen),
|
||||
}, 'display')
|
||||
display_devices[display_identifier] = iot_device
|
||||
x_screen += 1
|
||||
|
||||
if not len(display_devices):
|
||||
# No display connected, create "fake" device to be accessed from another computer
|
||||
|
||||
Reference in New Issue
Block a user