summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-08-22 09:15:41 +0200
committerSanto Cariotti <sancn@live.com>2017-08-22 09:15:41 +0200
commit8ee6331c0e8105134c0ac29cd4fceecd2968f89b (patch)
tree7aa1f8c9e5f69d93bbf4901810ab6a1de87f5d4c
parent6d987df8cd743bd16a4740a8d1f64fd6fa0e1c74 (diff)
add path
-rw-r--r--lib/app.py20
1 files changed, 14 insertions, 6 deletions
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)