From e0efeee67df3f2e63cc8f9cea1b57b4ce1b93be9 Mon Sep 17 00:00:00 2001 From: Darksider3 Date: Sun, 13 Oct 2019 22:44:30 +0200 Subject: [PATCH] Better error handling, just hang a freakin' / to ssh_dir if it got screwed up --- private/lib/System.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/private/lib/System.py b/private/lib/System.py index 6e915de..39421fd 100644 --- a/private/lib/System.py +++ b/private/lib/System.py @@ -6,6 +6,7 @@ import pwd class System: """Class to interact with the system specifically to support our needs 0w0""" + dry = False create_command = [] home = "" @@ -19,7 +20,12 @@ class System: :param home: Standard directory to search for the home directories of your users(default is /home/) :type home: str """ + self.dry = dryrun + if not home.endswith("/"): + home += "/" + if not os.path.isdir(home): + raise ValueError("home should be an existent directory...") self.home = home def register(self, username: str, cc: tuple = tuple(["useradd", "-m"])) -> bool: @@ -67,7 +73,7 @@ class System: print("Nah, @TODO, but actually kinda too lazy for this lul. Just a lot happening here") return True if not sshdir.endswith("/"): - return False # @TODO Exception in Log + sshdir += "/" ssh_dir = self.home + username + "/" + sshdir try: os.mkdir(ssh_dir)