-
Notifications
You must be signed in to change notification settings - Fork 0
/
jak_try.py
46 lines (37 loc) · 1.35 KB
/
jak_try.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/env python3
import subprocess, time, datetime
log= "/usr/share/hassio/homeassistant/pyscript/jak.csv"
ahora = datetime.datetime.now()
def repite():
try:
with open("/home/ha/jak_log.txt", "r") as c:
resultado = int(c.read()[-2])
with open('/home/ha/jak.txt', 'r') as d:
actual = d.read()
episodios=0
while resultado > 0:
episodios+=1
#almacena la proxima busqueda en txt
siguiente = int(actual)+1
#y modifica los archivos
with open('/home/ha/jak.txt', 'w') as h:
h.write(str(siguiente))
with open('/home/ha/jak.sh', 'w') as f:
f.write(f'raincoat "jak {str(siguiente)}"')
time.sleep(2)
subprocess.Popen(['sh','/home/ha/jak.sh'])
time.sleep(10)
with open('/home/ha/jak.txt', 'r') as d:
actual = d.read()
with open("/home/ha/jak_log.txt", "r") as c:
resultado = int(c.read()[-2])
with open(log, "a") as o:
o.write(f'{ahora.strftime("%d/%m/%Y")}, {episodios} nuevo(s): {int(actual)-1} el más reciente\n')
except Exception as e:
print(e)
def main():
subprocess.Popen(['sh','/home/ha/jak.sh'])
time.sleep(10)
repite()
if __name__== "__main__" :
main()