Created
January 25, 2018 01:49
-
-
Save tykling/c57c7ff5195c4adbe38b7e428d39a9e2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
sessions = AcsSession.objects.filter(inform_eventcodes=[]) | |
while i < 2852690: | |
sessions_slice = sessions[i:i+1000] | |
print "processing number %s - %s" % (i, i+1000) | |
for acss in sessions_slice: | |
if acss.inform_eventcodes: | |
continue | |
xmlroot = fromstring(acss.acs_http_conversationlist[-1].body.encode('utf-8')) | |
soap_body = xmlroot.find('soap-env:Body', settings.SOAP_NAMESPACES) | |
inform = soap_body.find('cwmp:Inform', settings.SOAP_NAMESPACES) | |
event = inform.find('Event') | |
eventcodes = [] | |
for es in event.findall('EventStruct'): | |
eventcodes.append(es.find('EventCode').text) | |
acss.inform_eventcodes = eventcodes | |
acss.save() | |
print("fixed %s - eventcodes: %s" % (acss, acss.inform_eventcodes)) | |
i+=1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment