From 8ee6331c0e8105134c0ac29cd4fceecd2968f89b Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 22 Aug 2017 09:15:41 +0200 Subject: add path --- lib/app.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'lib/app.py') diff --git a/lib/app.py b/lib/app.py index 2a8a14e..c5d68ec 100644 --- a/lib/app.py +++ b/lib/app.py @@ -1,6 +1,7 @@ from classes import r, clear, YELLOW, BLACK, GREY from commands import Commands from listcommands import ListCommands +import os.path class Stout(Commands): @@ -20,13 +21,16 @@ class Stout(Commands): """ if users exists, return username, else return an empty string """ - with open('/tmp/stout', 'rb') as fin: - user = fin.readline() + try: + with open('/tmp/stout', 'rb') as fin: + user = fin.readline() - if user == '': - return '' - else: - return user.decode('utf-8') + if user == '': + return '' + else: + return user.decode('utf-8') + except Exception: + return '' def action(self, cmd): """ @@ -64,6 +68,10 @@ if __name__ == '__main__': app = Stout() cmd = '' + + if not os.path.isfile('/tmp/stout'): + open('/tmp/stout', 'wb').close() + while cmd != 'quit': try: cmd = input('>' + YELLOW + app.getName() + BLACK) -- cgit v1.2.3-18-g5258