Skip to content

Commit

Permalink
gui: actually make Polkit optional
Browse files Browse the repository at this point in the history
If no versions of Polkit are available, skip the `gi.require_version`
call, or it will fail with ValueError even though it's an optional
dependency. This is necessary for the GUI to work on Homebrew and
Cygwin, which do not provide Polkit. Polkit isn't currently being used
for anything anyway.

Fixes this error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/shredder/__init__.py", line 11, in <module>
    gi.require_version('Polkit', '1.0')
  File "/usr/lib/python3.9/site-packages/gi/__init__.py", line 129, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Polkit not available

Fixes #613
  • Loading branch information
cebtenzzre committed Apr 18, 2023
1 parent b5a6d9b commit a807253
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gui/shredder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
gi.require_version('Gtk', '3.0')
gi.require_version('Rsvg', '2.0')
gi.require_version('PangoCairo', '1.0')
gi.require_version('Polkit', '1.0')
gi.require_version('GtkSource', '3.0')
if gi.Repository.get_default().enumerate_versions('Polkit'):
gi.require_version('Polkit', '1.0')

# Name of your application:
APP_TITLE = 'Shredder'
Expand Down

0 comments on commit a807253

Please sign in to comment.