From 05b2c03cf3971303354b3a188fbbb0bbb8d554fc Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Thu, 29 Nov 2012 16:18:29 +0000 Subject: Make json configs a bit smarter To get rid of the duplication in deps --- (limited to 'devbot/system.py') diff --git a/devbot/system.py b/devbot/system.py index 0bbfe8d..5757424 100644 --- a/devbot/system.py +++ b/devbot/system.py @@ -77,6 +77,17 @@ def _print_checks(checks): for check in checks: print "[%s] %s" % (check["checker"], check["check"]) +def _eval_check_if(check): + if "check_if" not in check: + return True + + distro_info = distro.get_distro_info() + globals = { "distro": "%s-%s" % (distro_info.name, distro_info.version) } + + print eval(check["check_if"], globals) + + return eval(check["check_if"], globals) == "True" + def run_checks(package_manager, checks, packages): distro_info = distro.get_distro_info() @@ -85,6 +96,10 @@ def run_checks(package_manager, checks, packages): to_install = [] for check in checks: + if not _eval_check_if(check): + print "uuuuu" + continue + checker = checkers[check["checker"]] if checker(check["check"]): if distro_info.name in packages[check["name"]]: -- cgit v0.9.1