From 9ff7e77ae569f9a45735e823b0b7e1d03f0222e5 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 5 Apr 2014 22:32:37 +0200 Subject: ...the python 3.4 way if using python 3.4 or newer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/__main__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/__main__.py b/src/__main__.py index 298568b..e5b3203 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -646,12 +646,20 @@ for key in l: settings = [gammas, rgb_brightnesses, cie_brightnesses, rgb_temperatures, cie_temperatures] if (config_file is None) and any([doreset, location] + settings): ## Use one time configurations - import importlib + # Get the Python version + v = sys.version_info # Load and execute adhoc.py with the same # globals as this module, so that it can # not only use want we have defined, but # also redefine it for us. - exec(importlib.find_loader('adhoc').get_code('adhoc'), g) + if (v.major > 3) or ((v.major == 3) and (v.minor >= 4)): + # The (new) Python 3.4 way + import importlib.util + exec(importlib.util.find_spec('adhoc').loader.get_code('adhoc'), g) + else: + # The deprecated legacy way + import importlib + exec(importlib.find_loader('adhoc').get_code('adhoc'), g) else: ## Load extension and configurations via blueshiftrc # No configuration script has been selected explicitly, -- cgit v1.2.3-70-g09d2