Better error handling, just hang a freakin' / to ssh_dir if it got screwed up

pull/4/head
Darksider3 5 years ago
parent 04d95c2d08
commit e0efeee67d

@ -6,6 +6,7 @@ import pwd
class System: class System:
"""Class to interact with the system specifically to support our needs 0w0""" """Class to interact with the system specifically to support our needs 0w0"""
dry = False dry = False
create_command = [] create_command = []
home = "" home = ""
@ -19,7 +20,12 @@ class System:
:param home: Standard directory to search for the home directories of your users(default is /home/) :param home: Standard directory to search for the home directories of your users(default is /home/)
:type home: str :type home: str
""" """
self.dry = dryrun 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 self.home = home
def register(self, username: str, cc: tuple = tuple(["useradd", "-m"])) -> bool: 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") print("Nah, @TODO, but actually kinda too lazy for this lul. Just a lot happening here")
return True return True
if not sshdir.endswith("/"): if not sshdir.endswith("/"):
return False # @TODO Exception in Log sshdir += "/"
ssh_dir = self.home + username + "/" + sshdir ssh_dir = self.home + username + "/" + sshdir
try: try:
os.mkdir(ssh_dir) os.mkdir(ssh_dir)

Loading…
Cancel
Save