-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremNow.py
More file actions
executable file
·32 lines (31 loc) · 1.02 KB
/
remNow.py
File metadata and controls
executable file
·32 lines (31 loc) · 1.02 KB
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
32
#!/usr/bin/env python
from time import *
from subprocess import *
REMFILE = ""
events = str(check_output(["rem", "-s+1", "-b1"]))
# the [:-1] eliminates wierdnon-unicode formatting
events_lines = events.split("\\n")[:-1]
fields = []
for line in events_lines:
fields.append(line.split())
#eliminates wierdnon-unicode formatting
fields[0][0] = fields[0][0][2:]
#transform interval start-end in two fields start, end
for lines in fields:
lines[5] = lines[5].split("-")
for i, lines in enumerate(fields):
if len(fields[i][5][1]) > 5:
fields[i][5][1] = fields[i][5][1][:5]
fields[i][0] = fields[i][0][:-2] + str(int(fields[i][0][8:]) + 1)
start = strptime((fields[i][0] + fields[i][5][0]), "%Y/%m/%d%H:%M")
end = strptime((fields[i][0] + fields[i][5][1]), "%Y/%m/%d%H:%M")
if start <= localtime() <= end:
inow = i
now = lines
break
try:
then = fields[(inow + 1)]
print(" ".join(now[6:-2]))
print(" ".join(then[6:]))
except NameError:
print("No Events\nAt all")