Created
May 22, 2015 16:32
-
-
Save flyte/56f4f31a0cad368110a7 to your computer and use it in GitHub Desktop.
Returns a JSON list of Jenkins plugins as keys and a boolean value representing their enabled status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import argparse | |
PLUGIN_EXTENSIONS = ("hpi", "jpi") | |
def plugin_name(path): | |
file_name = os.path.basename(path) | |
return file_name.split(".")[0] | |
def is_disabled(path): | |
_, ext = os.path.splitext(path) | |
return ext.lower() == ".disabled" | |
def is_plugin(path): | |
_, ext = os.path.splitext(path) | |
return ext.lower()[1:] in PLUGIN_EXTENSIONS | |
if __name__ == "__main__": | |
p = argparse.ArgumentParser() | |
p.add_argument("plugin_dir", help="The directory in which jenkins plugins reside") | |
args = p.parse_args() | |
items = os.listdir(args.plugin_dir) | |
plugins = [plugin_name(x) for x in filter(is_plugin, items)] | |
disabled_plugins = [plugin_name(x) for x in filter(is_disabled, items)] | |
ret = {} | |
for plugin in plugins: | |
ret[plugin] = plugin not in disabled_plugins | |
print json.dumps(ret, indent=2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment