← Back to team overview

nagios-charmers team mailing list archive

[Merge] ~peter-sabaini/hw-health-charm:fix-removing-sudoer into hw-health-charm:master

 

Peter Sabaini has proposed merging ~peter-sabaini/hw-health-charm:fix-removing-sudoer into hw-health-charm:master.

Requested reviews:
  Nagios Charm developers (nagios-charmers)

For more details, see:
https://code.launchpad.net/~peter-sabaini/hw-health-charm/+git/hw-health-charm/+merge/376195
-- 
Your team Nagios Charm developers is requested to review the proposed merge of ~peter-sabaini/hw-health-charm:fix-removing-sudoer into hw-health-charm:master.
diff --git a/src/lib/hwhealth/tools.py b/src/lib/hwhealth/tools.py
index fd6692d..2703fad 100644
--- a/src/lib/hwhealth/tools.py
+++ b/src/lib/hwhealth/tools.py
@@ -9,6 +9,7 @@ import shlex
 import shutil
 import subprocess
 
+from pathlib import Path
 from zipfile import ZipFile, BadZipFile
 from tempfile import TemporaryDirectory
 
@@ -209,9 +210,9 @@ class Tool():
         )
 
     def _remove_sudoer(self):
-        sudoer_path = os.path.join(self.SUDOERS_DIR, self._sudoer_file)
-        os.remove(sudoer_path)
-        hookenv.log('deleted sudoer file'.format(sudoer_path), hookenv.DEBUG)
+        sudoer_path = Path(self.SUDOERS_DIR) / self._sudoer_file
+        sudoer_path.unlink(missing_ok=True)
+        hookenv.log('deleted sudoer file: {}'.format(sudoer_path), hookenv.DEBUG)
 
 
 class VendorTool(Tool):

Follow ups