-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
59 lines (49 loc) · 1.56 KB
/
test.py
File metadata and controls
59 lines (49 loc) · 1.56 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from git import Repo
import subprocess
import git
import serial
import re
import time
port = '/dev/ttyACM0'
brate = 9600 #boudrate
cmd = 'temp'
repo = Repo.init('/home/plutonh')
seri = serial.Serial(port, baudrate = brate, timeout = None)
seri.write(cmd.encode())
#print(seri.name)
a = 1
can = 0
while a:
if seri.in_waiting != 0 :
content = seri.readline()
num = int(content[:-2].decode())
if num < 20:
state = "여유"
elif num >= 20 and num < 40:
state = "보통"
elif num >= 40 and num < 60:
state = "혼잡"
else :
state = "매우혼잡"
text = open('/home/plutonh/index_origin.html', 'r')
text = text.read()
changed_time = time.strftime('%Y-%m-%d %H:%M:%S ', time.localtime(time.time()))
text = text.replace('data', state)
text = text.replace('time', changed_time)
can = can + 1
#print(content[:-2].decode(), '\n', can)
#print(content[:-2].decode())
print(can)
with open('/home/plutonh/index.html', 'w') as f:
f.write(text)
f.close()
# adding, commiting and pushing command
if can == 1070: # can == 1070: approximately 1 minute
print(can)
repo.index.add(['index.html'])
repo.index.add(['test.py'])
repo.index.add(['Final_code.ino'])
repo.index.commit(changed_time)
origin = repo.remote(name = 'origin')
subprocess.call("git push -u origin master", shell = True)
can = 0