summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-09-17 14:19:45 +0200
committerSanto Cariotti <sancn@live.com>2017-09-17 14:19:45 +0200
commitf731b101668425fe3d675442b765dac53c9e27e7 (patch)
tree9e81138b4235d404057587b0dc334022e522fa46 /lib
parented348458515a1f678b914295bfd423623aef2ad4 (diff)
fixed 'set user' when file isn't empty
Diffstat (limited to 'lib')
-rw-r--r--lib/commands.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/commands.py b/lib/commands.py
index 663f231..942bc0e 100644
--- a/lib/commands.py
+++ b/lib/commands.py
@@ -19,8 +19,15 @@ class Commands(object):
self.user = cmd[2]
+ with open(co['path'], 'rb') as fin:
+ listOld = [x.decode('utf-8') for x in fin.readlines()]
+ del listOld[0]
+
with open(co['path'], 'wb') as fout:
fout.write((cmd[2] + '\n').encode('utf-8'))
+ for i in listOld:
+ fout.write((i).encode('utf-8'))
+ del listOld
print('Ok')
elif cmd[1] is not ListCommands.commands['set']:
@@ -82,6 +89,7 @@ class Commands(object):
try:
with open(co['path'], 'ab') as fout:
+ fout.seek(1, 1)
fout.write((msg + '\n').encode('utf-8'))
print('Ok')