aboutsummaryrefslogtreecommitdiffstats
path: root/src/nightshift.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-11 19:23:51 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-11 19:23:51 +0200
commitc030cc0c3398d9108a8bfbbd5b0d9ebf785847c4 (patch)
tree4bae39982af05be98473b81b1195a77a6fff7c72 /src/nightshift.py
parentsomethis we need to sleep when doing a panic kill (diff)
downloadnightshift-c030cc0c3398d9108a8bfbbd5b0d9ebf785847c4.tar.gz
nightshift-c030cc0c3398d9108a8bfbbd5b0d9ebf785847c4.tar.bz2
nightshift-c030cc0c3398d9108a8bfbbd5b0d9ebf785847c4.tar.xz
user interface continuously prints status in initialised terminal
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/nightshift.py')
-rwxr-xr-xsrc/nightshift.py38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/nightshift.py b/src/nightshift.py
index 0804a7d..7992311 100755
--- a/src/nightshift.py
+++ b/src/nightshift.py
@@ -635,25 +635,22 @@ def run():
do_client()
-def user_interface():
- '''
- Start user interface
- '''
- pass # TODO
- buf = ''
- continue_to_run = True
- while continue_to_run:
- while '\n\n' not in buf:
- got = sock.recv(1024)
- if (got is None) or (len(got) == 0):
- continue_to_run = False
- break
- buf += got.decode('utf-8', 'replace')
- if '\n\n' in buf:
- break
- msg, buf = buf.split('\n\n')[0] + '\n\n', '\n\n'.join(buf.split('\n\n')[1:])
- sys.stdout.buffer.write(msg.encode('utf-8'))
- sys.stdout.buffer.flush()
+g, l = globals(), dict(locals())
+for key in l:
+ g[key] = l[key]
+
+
+## Import interface.py with shared globals
+# Get the Python version
+v = sys.version_info
+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('interface').loader.get_code('interface'), g)
+else:
+ # The deprecated legacy way
+ import importlib
+ exec(importlib.find_loader('interface').get_code('interface'), g)
## Load extension and configurations via blueshiftrc
@@ -717,9 +714,6 @@ if config_file is not None:
# globals as this module, so that it can
# not only use want we have defined, but
# also redefine it for us.
- g, l = globals(), dict(locals())
- for key in l:
- g[key] = l[key]
exec(code, g)