Skip to content

Commit

Permalink
add some type hints & typecasts to run_command callers: user.py rocks…
Browse files Browse the repository at this point in the history
  • Loading branch information
phillxnet committed Mar 20, 2024
1 parent c06fdaa commit c03980a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/rockstor/system/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def usermod(username, passwd):
# crypted_passwd = crypt.crypt(passwd.encode("utf8"), salt_header + salt)
salt = crypt.mksalt()
crypted_passwd = crypt.crypt(passwd, salt)
cmd = [USERMOD, "-p", crypted_passwd, username]
cmd: list[str] = [USERMOD, "-p", crypted_passwd, username]
out, err, rc = run_command(cmd, log=True)
# p = subprocess.Popen(
# cmd,
Expand Down Expand Up @@ -236,7 +236,7 @@ def useradd(username, shell, uid=None, gid=None):
)
return [""], [""], 0

cmd = [USERADD, "-s", shell, "-m", username]
cmd: list[str] = [USERADD, "-s", shell, "-m", username]
if uid is not None:
cmd.insert(-1, "-u")
cmd.insert(-1, str(uid))
Expand All @@ -246,11 +246,11 @@ def useradd(username, shell, uid=None, gid=None):
return run_command(cmd)


def groupadd(groupname, gid=None):
cmd = [GROUPADD, groupname]
def groupadd(groupname: str, gid: int | None = None):
cmd: list[str] = [GROUPADD, groupname]
if gid is not None:
cmd.insert(-1, "-g")
cmd.insert(-1, gid)
cmd.insert(-1, str(gid))
return run_command(cmd)


Expand Down

0 comments on commit c03980a

Please sign in to comment.