From eb1c383fab33e9ac849be4344ae87d94e68dafe2 Mon Sep 17 00:00:00 2001 From: Lucio Delelis Date: Sun, 1 Jul 2018 14:51:54 -0300 Subject: [PATCH] Added a module to contain multiple user/group related tasks and utils --- patchwork/users.py | 10 ++++++++++ tasks.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 patchwork/users.py 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))