summaryrefslogtreecommitdiff
path: root/poezio
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2018-01-13 15:31:10 +0100
committermathieui <mathieui@mathieui.net>2018-01-13 15:31:10 +0100
commit6fe2f208337db898d370d7a2374b416d998b5b5f (patch)
tree2b585c5d4a155b0f592a4ea7972caaecb12f585c /poezio
parent391eb279640ea9250f5d16d44c4691a5b7d4efc1 (diff)
downloadpoezio-6fe2f208337db898d370d7a2374b416d998b5b5f.tar.gz
poezio-6fe2f208337db898d370d7a2374b416d998b5b5f.tar.bz2
poezio-6fe2f208337db898d370d7a2374b416d998b5b5f.tar.xz
poezio-6fe2f208337db898d370d7a2374b416d998b5b5f.zip
Enforce HOME, TERM, and PATH env vars when running
Instead of showing an ugly traceback
Diffstat (limited to 'poezio')
-rw-r--r--poezio/__main__.py8
-rw-r--r--poezio/poezio.py14
2 files changed, 18 insertions, 4 deletions
diff --git a/poezio/__main__.py b/poezio/__main__.py
index b0ba98e4..1f46f051 100644
--- a/poezio/__main__.py
+++ b/poezio/__main__.py
@@ -1,11 +1,11 @@
def run():
- from poezio.poezio import test_curses, main
+ from poezio.poezio import main, test_curses, test_env
- if test_curses():
- main()
- else:
+ if not test_curses() or not test_env():
import sys
sys.exit(1)
+ else:
+ main()
return 0
diff --git a/poezio/poezio.py b/poezio/poezio.py
index 51e10d1b..586130c8 100644
--- a/poezio/poezio.py
+++ b/poezio/poezio.py
@@ -37,6 +37,20 @@ Poezio is currently unable to read your input or draw its interface properly,\
so it will now exit.""")
return False
+def test_env():
+ """
+ Check if the environment has the right variables set
+ """
+ unset = set()
+ for i in ('HOME', 'PATH', 'TERM'):
+ if not os.environ.get(i):
+ unset.add(i)
+ if unset:
+ variables = ', '.join('$%s' % i for i in unset)
+ print('ERROR: %s not set' % variables)
+ return False
+ return True
+
def main():
"""