diff --git a/patchwork/users.py b/patchwork/users.py new file mode 100644 index 0000000..b302e54 --- /dev/null +++ b/patchwork/users.py @@ -0,0 +1,10 @@ +"""Various tasks for verifying user existence and attributes""" + +from .util import set_runner + + +@set_runner +def user_exists(c, runner, user): + """Returns True if the given system user exists.""" + cmd = "id {}".format(user) + return runner(cmd, hide=True, warn=True).ok diff --git a/tasks.py b/tasks.py index aa89672..919323e 100644 --- a/tasks.py +++ b/tasks.py @@ -13,7 +13,7 @@ def sanity(c): Quick sanity check to ensure we're installed successfully. Mostly for CI. """ # Doesn't need to literally import everything, but "a handful" will do. - for name in ('environment', 'files', 'transfers'): + for name in ('environment', 'files', 'transfers', 'users'): mod = "patchwork.{}".format(name) import_module(mod) print("Imported {} successfully".format(mod))