def UpdateLocalSQLite(JsessionID,umscrf,ChatListDepth=10,ChatMessagesDepth=10,MyMSISDN='+79262001222'): ''' UpdateLocalSQLite(JsessionID,umscrf,ChatListDepth=10,ChatMessagesDepth=10,MyMSISDN='+79262001222'): to be called every Time to update the Local Database from Server; ''' xml=xmlGetChatList(JsessionID,umscsrf) ChatLs=ChatLists(xml) # print "ChatLists To Insert:",ChatLs,"\n" insChats=dbAddChatList(ChatLs,ChatListDepth) # print "InsertedChats:",insChats for ChatItem in insChats: print MyMSISDN xml=xmlGetChat(JsessionID,umscsrf,MyMSISDN,ChatItem['MSISDN'],ChatMessagesDepth) # print xml MessageSet=Chat(xml) addedMessages=dbAddMessages(MessageSet) for msg in addedMessages: print 'AddedMessage: FROM:',msg['snd'],'TO:',msg['rcv'], 'TIME:',msg['t'],":" print '\t',msg['ttl']
MsgAttr=MsgAttr.nextSibling return MsgDict from UMSClientLogin import GetAuthParams from GetMessagesList import xmlGetChatList,xmlGetChat import ParseOptions if __name__ == '__main__': print "Main ParseXMLChatList:" (options,args)=ParseOptions.ParseOptions() (JsessionID,umscsrf)=GetAuthParams(options.name,options.password) print (JsessionID,umscsrf) xml=xmlGetChatList(JsessionID,umscsrf) ## print xml # of=open("./chats_unread.xml",'w') # of.write(xml) # of.close() ChatLs=ChatLists(xml) print "ChatLists:",ChatLs print ChatLs[0].keys() for i in ChatLs: print i xml=xmlGetChat(JsessionID,umscsrf,'+79262001222','+79262005826',10) Messages=Chat(xml) print "Chat:",Messages print Messages[0].keys() j=1 for i in Messages: print j,"\t",i['snd'],i['rcv'],i['msgID'],i['t'],":" print "\t\t",i['ttl'] j+=1 pass