Enforce HOME, TERM, and PATH env vars when running
Instead of showing an ugly traceback
This commit is contained in:
parent
391eb27964
commit
6fe2f20833
2 changed files with 18 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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():
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue