forked from tdamdouni/Raspberry-Pi-DIY-Projects
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhighping.py
executable file
·31 lines (23 loc) · 882 Bytes
/
highping.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
#!/usr/bin/env python
from __future__ import print_function
import os
import os.path
import time
#from Adafruit_CharLCD import Adafruit_CharLCD
os.environ['TZ'] = 'PST+08PDT,M4.1.0,M10.5.0'
time.tzset()
#include this program in another python script using `import highping` and then call the main function (and pass in arguements) using highping.main()
def main(ping):
if ping > 100:
fileWrite(ping)
def fileWrite(ping):
ping = str(ping)
f = open('/home/pi/Pi-Web-Status-Display/highpings.txt', 'a')
print(time.strftime("%c") + " -- Ping : " + ping + "ms", file=f)
print(time.strftime("%c") + " -- Ping : " + ping + "ms")
f.close()
currentTime = str(time.time( ))
f = open('/home/pi/Pi-Web-Status-Display/highpings.csv', 'a')
print(currentTime + ", " + ping, file=f)
print(currentTime + ", " + ping)
f.close()