-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhello.py
31 lines (29 loc) · 1013 Bytes
/
hello.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
# print("First name: " + sys.argv[1])
# print("Last name: " + sys.argv[2]
filepath = "FILES_SERVER/light.txt"
response = []
with open(filepath) as fp:
line = fp.readline()
cnt = 1
flag = False
while line:
try:
if (int(line[0:2]) and int(line[3:5]) and int(line[6:8])):
try:
if int(line[11]):
flag = True
except ValueError:
flag = False
if flag:
response.append(
{"Date": line[0:8], "Time": line[10:18], "Message": line[21:].split(":")})
line = fp.readline()
else:
response.append(
{"Date": line[0:8], "Time": line[10:17], "Message": line[20:].split(":")})
line = fp.readline()
except ValueError:
response[-1]['Message'][1] += line[0:]
line = fp.readline()
print(response)