-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflow.py
51 lines (46 loc) · 1.76 KB
/
flow.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
47
48
49
50
51
#!/usr/bin/python
import os
import sys
from twython import Twython
def test():
print 'Starting Speed Test'
a = os.popen("speedtest-cli --simple").read()
print 'Speed Test Complete'
lines = a.split('\n')
print a
#if speedtest could not connect set the speeds to 0
if "Cannot" in a:
p = 100
d = 0
u = 0
#extract the values for ping down and up values
else:
p = lines[0][6:11]
d = lines[1][10:14]
u = lines[2][8:12]
print date,p, d, u
APP_KEY = '' # Customer Key here
APP_SECRET = '' # Customer secret here
OAUTH_TOKEN = '' # Access Token here
OAUTH_TOKEN_SECRET = '' # Access Token Secret here
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
#This fi when de crosses dem net naa wuk
if "Cannot" in a:
try:
tweet="Hey @FLOWJamaica why is my internet down? I pay for 8down\\1up? #Fedup #PythonBot"
twitter.update_status(status=tweet)
except:
pass
elif eval(d)<8: #set de speed yasso
print "Attempting to Tweet FLOWJamaica"
try:
tweet="Hey @FLOWJamaica. Why is my speed " + d + " mbps down and " + u + " mbps up when I pay for 8mbps/1mbps #speedtest #PythonBot #FedUp @Garry4Flow "
twitter.update_status(status=tweet)
print tweet
except Exception,e:
print str(e)
pass
return
if __name__ == '__main__':
test()
print 'completed'