Skip to content

Commit

Permalink
Only try to remove files that exist during cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bayasdev committed Aug 17, 2024
1 parent 7a52eca commit 60bd37a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions envycontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,21 @@ def cleanup():
UDEV_PM_PATH,
XORG_PATH,
EXTRA_XORG_PATH,
'/etc/X11/xorg.conf.d/90-nvidia.conf',
MODESET_PATH,
LIGHTDM_SCRIPT_PATH,
LIGHTDM_CONFIG_PATH,
# legacy files
'/etc/X11/xorg.conf.d/90-nvidia.conf',
'/lib/udev/rules.d/50-remove-nvidia.rules',
'/lib/udev/rules.d/80-nvidia-pm.rules'
]

# remove each file in the list
for file_path in to_remove:
try:
os.remove(file_path)
logging.info(f"Removed file {file_path}")
if os.path.exists(file_path):
os.remove(file_path)
logging.info(f"Removed file {file_path}")
except OSError as e:
# only warn if file exists (code 2)
if e.errno != 2:
Expand Down

0 comments on commit 60bd37a

Please sign in to comment.