mirror of https://gitlab.com/bashrc2/epicyon
Add exception handling
parent
d826ded287
commit
ccd06e614f
12
theme.py
12
theme.py
|
@ -431,14 +431,22 @@ def _set_background_format(base_dir: str,
|
|||
css_filename = base_dir + '/' + background_type + '.css'
|
||||
if not os.path.isfile(css_filename):
|
||||
return
|
||||
|
||||
css = None
|
||||
try:
|
||||
with open(css_filename, 'r', encoding='utf-8') as fp_css:
|
||||
css = fp_css.read()
|
||||
except OSError as exc:
|
||||
print('EX: _set_background_format 1 ' + css_filename + ' ' + str(exc))
|
||||
|
||||
if css:
|
||||
css = css.replace('background.jpg', 'background.' + extension)
|
||||
try:
|
||||
with open(css_filename, 'w+', encoding='utf-8') as fp_css2:
|
||||
fp_css2.write(css)
|
||||
except OSError as ex:
|
||||
print('EX: _set_background_format ' + css_filename + ' ' + str(ex))
|
||||
except OSError as exc:
|
||||
print('EX: _set_background_format 2 ' +
|
||||
css_filename + ' ' + str(exc))
|
||||
|
||||
|
||||
def enable_grayscale(base_dir: str) -> None:
|
||||
|
|
Loading…
Reference in New Issue