Last active
December 19, 2015 03:08
-
-
Save fndiaz/5887486 to your computer and use it in GitHub Desktop.
manipulando xml com ajax jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_xml(): | |
cj = CookieJar() | |
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) | |
opener.open("http://192.168.1.100/astmanager/asterisk/mxml?action=login&username=admanager&secret=ad9898") | |
tree = ElementTree(file=opener.open('http://192.168.1.100/astmanager/asterisk/mxml?action=queuestatus')) | |
#print tree | |
r = tree.getroot() | |
#print r | |
pessoa = r.find('response') | |
print pessoa.attrib | |
a=0 | |
lista=[] | |
fila=[] | |
for child in r: | |
for var in child: | |
if a == 0: | |
print var.attrib['message'] | |
print '>>>>>>>>>>' | |
a=a+1 | |
else: | |
evento = var.attrib['event'] | |
if evento == 'QueueParams': | |
if fila == []: #primeira entrada nome da fila | |
fila.append(var.attrib['queue']) | |
print var.attrib['queue'] | |
print '>>>>>>>>>>' | |
else: #demais entradas noma da fila | |
lista.append(fila) | |
fila=[] | |
fila.append(var.attrib['queue']) | |
print var.attrib['queue'] | |
print '>>>>>>>>>>' | |
elif evento == 'QueueMember': #entrada membros da fila | |
print var.attrib['name'] | |
fila.append(var.attrib['name']) | |
#print fila | |
elif evento == 'QueueStatusComplete': #ultima entrada | |
lista.append(fila) | |
#for lin in lista: | |
# lista = lin | |
return response.json(lista) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment