diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-02-16 19:53:06 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-02-16 19:53:06 +0100 |
commit | 06f7f1f9f25cbf6ca947f3bb6a6ed4fd7b7e3c4d (patch) | |
tree | 5a00eb582f0d41fd72b97c3b7c79d08f43c59081 /src/__main__.py | |
parent | m todo (diff) | |
download | blueshift-06f7f1f9f25cbf6ca947f3bb6a6ed4fd7b7e3c4d.tar.gz blueshift-06f7f1f9f25cbf6ca947f3bb6a6ed4fd7b7e3c4d.tar.bz2 blueshift-06f7f1f9f25cbf6ca947f3bb6a6ed4fd7b7e3c4d.tar.xz |
working with some exceptions
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/__main__.py')
-rwxr-xr-x | src/__main__.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/__main__.py b/src/__main__.py index f8db7a2..8fd4235 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -20,6 +20,12 @@ import time import signal import datetime + +## Set global variables +global DATADIR, i_size, o_size, r_curve, g_curve, b_curve, clip_result +global periodically, wait_period, monitor_controller, running + + from solar import * from curve import * from colour import * @@ -29,11 +35,6 @@ from monitor import * config_file = None -## Set globals variables -global DATADIR, i_size, o_size, r_curve, g_curve, b_curve, clip_result -global periodically, wait_period, monitor_controller, running - - def periodically(year, month, day, hour, minute, second, weekday, fade): fadein_time = None fadeout_time = None @@ -133,23 +134,27 @@ if config_file is None: for file in ('$XDG_CONFIG_HOME/%/%rc', '$HOME/.config/%/%rc', '$HOME/.%rc', '/etc/%rc'): file = file.replace('%', 'blueshift') for arg in ('XDG_CONFIG_HOME', 'HOME'): - if arg in os.environ: - print(arg) - file = file.replace('$' + arg, os.environ[arg].replace('$', '\0')) - else: - file = None - break + if '$' + arg in file: + if arg in os.environ: + file = file.replace('$' + arg, os.environ[arg].replace('$', '\0')) + else: + file = None + break if file is not None: file = file.replace('\0', '$') if os.path.exists(file): config_file = file + break if config_file is not None: code = None with open(file, 'rb') as script: code = script.read() code = code.decode('utf8', 'error') + '\n' code = compile(code, file, 'exec') - exec(code, globals) + g, l = globals(), dict(locals()) + for key in l: + g[key] = l[key] + exec(code, g) else: print('No configuration file found') sys.exit(1) |