Skip to content

Commit

Permalink
fix crash if trigger isn't set
Browse files Browse the repository at this point in the history
The GUI defaulted to 'lock-screen', but the CLI did not. And it was crashing if 'trigger' wasn't defined in the config file when executed over the CLI. This fixes it

 * #14 (comment)

	INFO: using DATA_DIR:|/home/user/.local/share/.buskill|
	DEBUG: CONF_FILE:|/home/user/.local/share/.buskill/config.ini|

	Traceback (most recent call last):
  	File "/tmp/.mount_buskilReWwl8/opt/python3.7/lib/python3.7/configparser.py", line 788, in get
    	value = d[option]
  	File "/tmp/.mount_buskilReWwl8/opt/python3.7/lib/python3.7/collections/__init__.py", line 916, in __getitem__
    	return self.__missing__(key)            # support subclasses that define __missing__
  	File "/tmp/.mount_buskilReWwl8/opt/python3.7/lib/python3.7/collections/__init__.py", line 908, in __missing__
    	raise KeyError(key)
	KeyError: 'trigger'

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
  	File "/tmp/.mount_buskilReWwl8/opt/src/main.py", line 129, in <module>
    	bk = packages.buskill.BusKill()
  	File "/tmp/.mount_buskilReWwl8/opt/src/packages/buskill/__init__.py", line 426, in __init__
    	self.set_trigger( self.config.get('buskill', 'trigger') )
  	File "/tmp/.mount_buskilReWwl8/opt/python3.7/lib/python3.7/configparser.py", line 791, in get
    	raise NoOptionError(option, section)
	configparser.NoOptionError: No option 'trigger' in section: 'buskill'
	user@disp6142:~/buskill-lin--x86_64$
	user@disp6142:~/buskill-lin--x86_64$ ./buskill-.AppImage --arm
  • Loading branch information
maltfield committed Jun 13, 2023
1 parent 0fe7ade commit ba71e44
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/packages/buskill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,11 @@ def __init__(self):
# set the default trigger to what's defined in the config file
self.config = configparser.ConfigParser()
self.config.read( self.CONF_FILE )
self.set_trigger( self.config.get('buskill', 'trigger') )
if self.config.has_option('buskill', 'trigger'):
trigger = self.config.get('buskill', 'trigger')
else:
trigger = 'lock-screen'
self.set_trigger( trigger )

# handle conditions where this version was already upgraded by a newer
# version or if this is a version that upgraded an older version
Expand Down

0 comments on commit ba71e44

Please sign in to comment.