Initial Code Commit
This commit is contained in:
parent
58d950c2fa
commit
e0c8d75c2f
62
main.py
Normal file
62
main.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import urllib2
|
||||||
|
import json
|
||||||
|
import ssl
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
from pprint import pprint
|
||||||
|
from win10toast import ToastNotifier
|
||||||
|
|
||||||
|
toaster = ToastNotifier()
|
||||||
|
|
||||||
|
myExtension = 1254
|
||||||
|
|
||||||
|
nocURL = "https://noc.ventraip.net.au/new/api.php"
|
||||||
|
context = ssl._create_unverified_context()
|
||||||
|
|
||||||
|
phoneQueues = {"QUEUE618":"Synergy Sales","QUEUE285":"Ventra Sales","QUEUE384":"Synergy Technical","QUEUE286":"Ventra Billing","QUEUE284":"Ventra Technical"}
|
||||||
|
|
||||||
|
ringing = False
|
||||||
|
|
||||||
|
def getNOCData(URL):
|
||||||
|
data = urllib2.urlopen(URL, context=context)
|
||||||
|
jsonData = json.loads(data.read())
|
||||||
|
#file = open('testData.json')
|
||||||
|
#jsonData = json.load(file)
|
||||||
|
return jsonData
|
||||||
|
|
||||||
|
def amRinging(ring, queue):
|
||||||
|
global ringing
|
||||||
|
if ring == True:
|
||||||
|
toaster.show_toast(phoneQueues[queue],
|
||||||
|
"Is ringing :(",
|
||||||
|
icon_path=None,
|
||||||
|
# duration=20,
|
||||||
|
threaded=True)
|
||||||
|
ringing = False
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# while True:
|
||||||
|
# data = getNOCData(nocURL)
|
||||||
|
# pprint(data)
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
data = getNOCData(nocURL)
|
||||||
|
#pprint(data["queues"])
|
||||||
|
except urllib2.URLError, e:
|
||||||
|
print(str(e.reason))
|
||||||
|
continue
|
||||||
|
|
||||||
|
for queue in phoneQueues:
|
||||||
|
queueData = data["queues"][queue]["loggedIn"]
|
||||||
|
#print("The queue is %s" % phoneQueues[queue])
|
||||||
|
for extension in queueData:
|
||||||
|
#print("\t%s" % extension)
|
||||||
|
if data["queues"][queue]["calls"] > 0:
|
||||||
|
if extension["extension"] == myExtension:
|
||||||
|
#print(extension["status"])
|
||||||
|
if extension["status"] == 6:
|
||||||
|
ringing = True
|
||||||
|
else:
|
||||||
|
ringing = False
|
||||||
|
amRinging(ringing, queue)
|
||||||
|
time.sleep(1)
|
||||||
Loading…
x
Reference in New Issue
Block a user