digitaltrails / vdu_controls

VDU controls - a control panel for monitor brightness/contrast/...
GNU General Public License v3.0
103 stars 4 forks source link

Does not launch on Kubuntu 23.04 / Python 3.11 / ddcutil 1.4.1 #60

Closed andreondra closed 9 months ago

andreondra commented 9 months ago

After downloading and launching the script (I tried both latest release and latest commit on master) an error is shown: Error: AttributeError: PRESERVE_WINDOW_STATE Is the sleep-multiplier setting too low? and GUI won't launch.

Here is the traceback:

Traceback (most recent call last):
  File "/home/golas/Plocha/vdu_controls-1.11.0/vdu_controls.py", line 7717, in <module>
    main()
  File "/home/golas/Plocha/vdu_controls-1.11.0/vdu_controls.py", line 7546, in main
    VduAppWindow(main_config, app, main_controller)  # may need to assign this to a variable to prevent garbage collection?
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/golas/Plocha/vdu_controls-1.11.0/vdu_controls.py", line 7035, in __init__
    self.show_main_window()
  File "/home/golas/Plocha/vdu_controls-1.11.0/vdu_controls.py", line 7087, in show_main_window
    if len(self.settings.allKeys()) == 0 and self.main_config.is_set(ConfOption.PRESERVE_WINDOW_STATE):
                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 783, in __getattr__
    raise AttributeError(name) from None
AttributeError: PRESERVE_WINDOW_STATE

If I comment out the check on the line 7087 which caused the error, the GUI launches just fine. However, if I open settings, same error complaining about sleep-multiplier is shown again and the GUI crashes.

digitaltrails commented 9 months ago

Thanks for taking the time to report this.

When testing a new install I forgot to delete ~/.config/vdu_controls.qt.state, so this condition was never tested. I had renamed a constant, but somehow missed one instance of the old name. I've pushed a fix. I'll also need to prepare a new release as this is a pretty bad error.

If you're getting errors related to the sleep-multiplier, they're most likely for a different reason. If the error isn't giving you a stacktrace, you might have to enable debugging and post the log:

% python3 vdu_controls --debug

Sleep multiplier errors may occur if there is an issue with communicating with a monitor. But they shouldn't cause a crash, so this is quite interesting/disappointing.

andreondra commented 9 months ago

Hello, thanks for the quick response.

The fix you pushed worked, now the GUI launches without problems. However, the problem with the settings causing a crash still persists. Here are the logs:

10:09:37 INFO: splash_message: 'Checking Presets'
10:09:37 DEBUG: SingletonDialog exists SettingsEditor False
10:09:37 DEBUG: configure: released application_configuration_lock
10:09:37 INFO: Completed configuring application
10:09:47 DEBUG: SingletonDialog exists SettingsEditor False
10:09:47 DEBUG: SingletonDialog created for SettingsEditor
10:09:47 ERROR: 
Traceback (most recent call last):
  File "/home/golas/Repos/vdu_controls/vdu_controls.py", line 6592, in edit_config
    SettingsEditor.invoke(self.main_config, self.get_vdu_configs(), self.settings_changed)
  File "/home/golas/Repos/vdu_controls/vdu_controls.py", line 2126, in invoke
    SettingsEditor.show_existing_dialog() if SettingsEditor.exists() else SettingsEditor(default_config,
                                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/golas/Repos/vdu_controls/vdu_controls.py", line 2142, in __init__
    self.reconfigure([default_config, *vdu_config_list])
  File "/home/golas/Repos/vdu_controls/vdu_controls.py", line 2148, in reconfigure
    tab = SettingsEditorTab(self, config, self.change_callback, parent=self.tabs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/golas/Repos/vdu_controls/vdu_controls.py", line 2200, in __init__
    self.ini_editable = self.ini_before.duplicate()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/golas/Repos/vdu_controls/vdu_controls.py", line 1698, in duplicate
    new_ini[section][option] = self[section][option]
    ~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.11/configparser.py", line 1278, in __setitem__
    return self._parser.set(self._name, key, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/configparser.py", line 1220, in set
    super().set(section, option, value)
  File "/usr/lib/python3.11/configparser.py", line 910, in set
    value = self._interpolation.before_set(self, section, option,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/configparser.py", line 403, in before_set
    raise ValueError("invalid interpolation syntax in %r at "
ValueError: invalid interpolation syntax in 'Model: 245E1\nMCCS version: 2.2\nCommands:\n   Op Code: 01 (VCP Request)\n   Op Code: 02 (VCP Response)\n   Op Code: 03 (VCP Set)\n   Op Code: 07 (Timing Request)\n   Op Code: 0C (Save Settings)\n   Op Code: E3 (Capabilities Reply)\n   Op Code: F3 (Capabilities Request)\nVCP Features:\n   Feature: 02 (New control value)\n   Feature: 04 (Restore factory defaults)\n   Feature: 05 (Restore factory brightness/contrast defaults)\n   Feature: 08 (Restore color defaults)\n   Feature: 0B (Color temperature increment)\n   Feature: 0C (Color temperature request)\n   Feature: 10 (Brightness)\n   Feature: 12 (Contrast)\n   Feature: 14 (Select color preset)\n      Values:\n         01: sRGB\n         04: 5000 K\n         05: 6500 K\n         06: 7500 K\n         07: 8200 K\n         08: 9300 K\n         0a: 11500 K\n         0b: User 1\n   Feature: 16 (Video gain: Red)\n   Feature: 18 (Video gain: Green)\n   Feature: 1A (Video gain: Blue)\n   Feature: 52 (Active control)\n   Feature: 54 (Performance Preservation)\n      Values: 00 01 (interpretation unavailable)\n   Feature: 60 (Input Source)\n      Values:\n         01: VGA-1\n         11: HDMI-1\n         0f: DisplayPort-1\n   Feature: 62 (Audio speaker volume)\n      Values: 00 01 (interpretation unavailable)\n   Feature: 6C (Video black level: Red)\n   Feature: 6E (Video black level: Green)\n   Feature: 70 (Video black level: Blue)\n   Feature: 72 (Gamma)\n      Specific presets of absolute adjustment supported (0xfb)\n      Absolute tolerance: +/- 5% (=0x05)\n      Native gamma: 2.20 (0x78)\n      Specific presets:  1.80 (0x50), 2.00 (0x64), 2.20 (0x78), 2.40 (0x8c), 2.60 (0xa0)\n   Feature: 86 (Display Scaling)\n      Values:\n         02: Max image, no aspect ration distortion\n         08: Linear expansion (compression) on h and v axes\n   Feature: 87 (Sharpness)\n   Feature: 8D (Audio mute/Screen blank)\n      Values: 00 01 (interpretation unavailable)\n   Feature: AC (Horizontal frequency)\n   Feature: AE (Vertical frequency)\n   Feature: B2 (Flat panel sub-pixel layout)\n   Feature: B6 (Display technology type)\n   Feature: C0 (Display usage time)\n   Feature: C6 (Application enable key)\n   Feature: C8 (Display controller type)\n   Feature: CA (OSD/Button Control)\n      Values:\n         01: OSD disabled, button events enabled\n         02: OSD enabled, button events enabled\n   Feature: CC (OSD Language)\n      Values:\n         01: Chinese (traditional, Hantai)\n         02: English\n         03: French\n         04: German\n         05: Italian\n         06: Japanese\n         07: Korean\n         08: Portuguese (Portugal)\n         09: Russian\n         0a: Spanish\n         0b: Swedish\n         0c: Turkish\n         0d: Chinese (simplified / Kantai)\n         0e: Portuguese (Brazil)\n         12: Czech\n         14: Dutch\n         16: Finnish\n         17: Greek\n         1a: Hungarian\n         1e: Polish\n         24: Ukranian\n   Feature: D6 (Power mode)\n      Values:\n         01: DPM: On,  DPMS: Off\n         04: DPM: Off, DPMS: Off\n         05: Write only value to turn off display\n   Feature: DC (Display Mode)\n      Values:\n         00: Standard/Default mode\n         01: Productivity\n         02: Mixed\n         03: Movie\n         05: Games\n         08: Standard/Default mode with intermediate power consumption\n   Feature: DF (VCP Version)\n   Feature: E9 (Manufacturer specific feature)\n      Values: 00 02 (interpretation unavailable)\n   Feature: EB (Manufacturer specific feature)\n      Values: 00 01 02 03 (interpretation unavailable)\n   Feature: F0 (Manufacturer specific feature)\n      Values: 00 01 (interpretation unavailable)\n   Feature: FD (Manufacturer specific feature)\n   Feature: FF (Manufacturer specific feature)\n' at position 1469

10:09:50 INFO: App exit rc=0 
digitaltrails commented 9 months ago

This second crash seems to be due to something in the DDC Capabilities description of the monitor that python configparser doesn't like. I've not seen that before, most likely you're the first person to try vdu_controls with this make and model, or the first to bother raising an issue, thanks for taking the time to do so.

The at position 1469 indicates there is a parse problem inside the gamma feature definition. It's the percent sign in the gamma feature spec. Gamma isn't often supported, this is probably the first time it's been encountered specified in this format.

I've reproduced the issue by simulating this particular monitors definition.

The capabilities text appears to be:

Model: 245E1
MCCS version: 2.2
Commands:
   Op Code: 01 (VCP Request)
   Op Code: 02 (VCP Response)
   Op Code: 03 (VCP Set)
   Op Code: 07 (Timing Request)
   Op Code: 0C (Save Settings)
   Op Code: E3 (Capabilities Reply)
   Op Code: F3 (Capabilities Request)
VCP Features:
   Feature: 02 (New control value)
   Feature: 04 (Restore factory defaults)
   Feature: 05 (Restore factory brightness/contrast defaults)
   Feature: 08 (Restore color defaults)
   Feature: 0B (Color temperature increment)
   Feature: 0C (Color temperature request)
   Feature: 10 (Brightness)
   Feature: 12 (Contrast)
   Feature: 14 (Select color preset)
      Values:
         01: sRGB
         04: 5000 K
         05: 6500 K
         06: 7500 K
         07: 8200 K
         08: 9300 K
         0a: 11500 K
         0b: User 1
   Feature: 16 (Video gain: Red)
   Feature: 18 (Video gain: Green)
   Feature: 1A (Video gain: Blue)
   Feature: 52 (Active control)
   Feature: 54 (Performance Preservation)
      Values: 00 01 (interpretation unavailable)
   Feature: 60 (Input Source)
      Values:
         01: VGA-1
         11: HDMI-1
         0f: DisplayPort-1
   Feature: 62 (Audio speaker volume)
      Values: 00 01 (interpretation unavailable)
   Feature: 6C (Video black level: Red)
   Feature: 6E (Video black level: Green)
   Feature: 70 (Video black level: Blue)
   Feature: 72 (Gamma)
      Specific presets of absolute adjustment supported (0xfb)
      Absolute tolerance: +/- 5% (=0x05)
      Native gamma: 2.20 (0x78)
      Specific presets:  1.80 (0x50), 2.00 (0x64), 2.20 (0x78), 2.40 (0x8c), 2.60 (0xa0)
   Feature: 86 (Display Scaling)
      Values:
         02: Max image, no aspect ration distortion
         08: Linear expansion (compression) on h and v axes
   Feature: 87 (Sharpness)
   Feature: 8D (Audio mute/Screen blank)
      Values: 00 01 (interpretation unavailable)
   Feature: AC (Horizontal frequency)
   Feature: AE (Vertical frequency)
   Feature: B2 (Flat panel sub-pixel layout)
   Feature: B6 (Display technology type)
   Feature: C0 (Display usage time)
   Feature: C6 (Application enable key)
   Feature: C8 (Display controller type)
   Feature: CA (OSD/Button Control)
      Values:
         01: OSD disabled, button events enabled
         02: OSD enabled, button events enabled
   Feature: CC (OSD Language)
      Values:
         01: Chinese (traditional, Hantai)
         02: English
         03: French
         04: German
         05: Italian
         06: Japanese
         07: Korean
         08: Portuguese (Portugal)
         09: Russian
         0a: Spanish
         0b: Swedish
         0c: Turkish
         0d: Chinese (simplified / Kantai)
         0e: Portuguese (Brazil)
         12: Czech
         14: Dutch
         16: Finnish
         17: Greek
         1a: Hungarian
         1e: Polish
         24: Ukranian
   Feature: D6 (Power mode)
      Values:
         01: DPM: On,  DPMS: Off
         04: DPM: Off, DPMS: Off
         05: Write only value to turn off display
   Feature: DC (Display Mode)
      Values:
         00: Standard/Default mode
         01: Productivity
         02: Mixed
         03: Movie
         05: Games
         08: Standard/Default mode with intermediate power consumption
   Feature: DF (VCP Version)
   Feature: E9 (Manufacturer specific feature)
      Values: 00 02 (interpretation unavailable)
   Feature: EB (Manufacturer specific feature)
      Values: 00 01 02 03 (interpretation unavailable)
   Feature: F0 (Manufacturer specific feature)
      Values: 00 01 (interpretation unavailable)
   Feature: FD (Manufacturer specific feature)
   Feature: FF (Manufacturer specific feature)
digitaltrails commented 9 months ago

I've pushed a change which removes percent signs from the capabilities text. It's probably not the complete/proper solution but I hope it might get you going.

It's end of day here, I'll take a harder look at this tomorrow afternoon.

andreondra commented 9 months ago

Looks good, now it does not crash. Thank you. I'll be happy to test further fixes if you would like to.

digitaltrails commented 9 months ago

Thanks, that confirms the cause of the issue.

I've just pushed a permanent fix. It looks like I had encountered similar issues with % in the past, but had just patched around the issue, but had not covered all cases.

I found a general solution in the ConfigParser documentation. I've disabled the special treatment of % in the python ConfigParser parser (disabled % interpolation). Hopefully %-signs should no longer be an issue anywhere in the config file values.

I don't think you will encounter any issues with this further change, but if you'd like to test it, you can do so by starting without a config file. Everything should load fine, and the % sign will actually be retrieved and saved without issue.

I will look to release v1.11.1 as a release later today (after I do a bit more testing).

digitaltrails commented 9 months ago

Fix released in v1.11.1