summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-05 22:32:37 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-05 22:32:37 +0200
commit9ff7e77ae569f9a45735e823b0b7e1d03f0222e5 (patch)
treebc3799fae2673d6e6b95a41a758b82ba13625bd9 /src
parentimprove execution of adhoc.py (diff)
downloadblueshift-9ff7e77ae569f9a45735e823b0b7e1d03f0222e5.tar.gz
blueshift-9ff7e77ae569f9a45735e823b0b7e1d03f0222e5.tar.bz2
blueshift-9ff7e77ae569f9a45735e823b0b7e1d03f0222e5.tar.xz
...the python 3.4 way if using python 3.4 or newer
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rwxr-xr-xsrc/__main__.py12
1 files 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,