From eecbc2d35b36a70e6e3f632fb6ec98fe59758d61 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Fri, 22 Sep 2017 17:42:29 -0700 Subject: [PATCH] Add certbot.hooks.list_hooks --- certbot/hooks.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/certbot/hooks.py b/certbot/hooks.py index 799ef90b7..e4cc63f90 100644 --- a/certbot/hooks.py +++ b/certbot/hooks.py @@ -151,3 +151,15 @@ def execute(shell_cmd): logger.error('Error output from %s:\n%s', base_cmd, err) return (err, out) + +def list_hooks(dir_path): + """List paths to all hooks found in dir_path in sorted order. + + :param str dir_path: directory to search + + :returns: `list` of `str` + :rtype: sorted list of absolute paths to executables in dir_path + + """ + paths = (os.path.join(dir_path, f) for f in os.listdir(dir_path)) + return sorted(path for path in paths if util.is_exe(path))