-
Notifications
You must be signed in to change notification settings - Fork 0
/
VoipReadVer.py
97 lines (71 loc) · 2.68 KB
/
VoipReadVer.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from voipms import VoipMs
from datetime import datetime
import time
import matplotlib.pyplot as plt
import matplotlib
#dummy change; remove this
#from Utils import showModulePath
import Utils
def sendSMS(src, dst, msg):
client.dids.send.sms(src,dst, msg)
filedata=Utils.getPWFile()
Utils.showModulePath(VoipMs)
#raise AssertionError("Unexpected value of 'distance'!", 11)
#raise Exception('bad thing happened')
#Load the JSON file with pwrd
client = VoipMs(filedata['un'], filedata['pw'] )
status=client.accounts.get.registration_status('136817_CELL3')
print(status)
print('now sending sms')
sendSMS(filedata['DID'], filedata['DID'], 'AHOY DUDE')
import DataTest
#from voipms import VoipMs
#client = VoipMs('', '')
a=client.accounts.get.registration_status('136817_CELL3')
print('cell phone registered? ' + a['registered'])
'''
a=client.accounts.get.registration_status('136817_HOME')
print('home phone registered? ' + a['registered'])
a=client.accounts.get.registration_status('136817_CELL')
print('\defunct phone registered? ' + a['registered'])
'''
TIME_ARRAY=[]
REGISTRATION_ARRAY=[]
VOIPMS_LOGFILE='VoipMS_Logfile.csv'
with open(VOIPMS_LOGFILE, "a", newline="\r\n") as text_file:
text_file.write('*'*10 + "\n")
timeValue=datetime.now().strftime('%Y-%m-%d, %H:%M:%S')
text_file.write('NEW LOG STARTED AT: ' + timeValue +'\n' )
i=-1
while 1:
i=i+1
timeValue=datetime.now().strftime('%Y-%m-%d, %H:%M:%S')
TIME_ARRAY.append(timeValue) #Store the data
# ref: https://stackoverflow.com/questions/26455616/how-can-i-create-basic-timestamps-or-dates-python-3-4
x2 = [datetime.strptime(elem, '%Y-%m-%d, %H:%M:%S') for elem in TIME_ARRAY]
dates=matplotlib.dates.date2num(x2)
try:
status=client.accounts.get.registration_status('136817_CELL3')
except:
print('Iteration skipped! could not log into voip.ms..retrying')
continue
#print('cell phone registered? ' + status['registered'])
registerstatus= int(status['registered']=='yes')
REGISTRATION_ARRAY.append(registerstatus)
outstring=timeValue + ", CellStatus , " + "{first}".format(first=registerstatus)
print(outstring)
#Append contents to file
with open(VOIPMS_LOGFILE, "a", newline="\r\n") as text_file:
text_file.write(outstring +'\n')
#print(timeValue + ", CellStatus= " + "{first}".format(first=registerstatus))
#Update plot
'''
# ref https://stackoverflow.com/questions/11874767/real-time-plotting-in-while-loop-with-matplotlib
plt.ion()
matplotlib.pyplot.plot_date(dates, REGISTRATION_ARRAY)
(fig, ax) = plt.subplots(1, 1)
ax.plot(dates, REGISTRATION_ARRAY)
fig.show()
plt.pause(0.05)
'''
time.sleep(1)