import logs, os, codecs import appuifw import time import contacts co=contacts.open() ep='e:\calllogs\' rt=time.time() # for countries east of GMT i.e. GMT+xy hrs rt=rt+str(-(time.timezone)) # being in india i use GMT+(-19800) #rt = rt + 19800 rt=time.gmtime(rt) #Dr.MiT, Hyderabad, INDIA tp=str(rt[0])+'_'+str(rt[1])+'_'+str(rt[2])+'_'+str(rt[3])+'_'+str(rt[4])+'_'+str(rt[5])+'_calllog.txt' #tp=str(rt[0])+'_'+str(rt[1])+'_'+str(tr[2])+'_'+str(rt[3])+'_'+ #str(rt[4])+'_'+str(rt[5])+'_calllog.txt' #if this line extends beyond ur display, press "'ctrl'+'-'" to decrease the size #(ctrl)+(+) to increase the webpage display size #(ctrl)+(-) to decrease the webpage display size fn=ep+tp nl='\n' ts=time.asctime() ttza=time.timezone sttza=str(ttza) ttzb=ttza+39600 sttzb=str(ttzb) sf=codecs.open(fn,'w','utf8') sf.write(nl+'ttza=time.timezone is '+ttza+nl) sf.write(nl+'ttzb=ttza+39600 is '+sttzb+nl) sf.write(nl+'Today is '+str(ts)+nl) e=['out','missed','in'] for x in e: l=logs.calls(mode=x) for i in range(len(l)): dim=ttzb+(l[i]["time"]) dim=time.localtime(dim) # lm=time.timezone() # dim=dim+(time.timezone) dateim= time.strftime("%Y/%m/%d-%H:%M:%S", dim) daasc= time.asctime(dim) s=str(dateim)+" "+str(daasc)+(" M:")+str(l[i]["direction"]) s=s+(" D:")+str(l[i]["duration"]) s=s+(" N:")+str(l[i]["number"]) nln=" ;" s=s+nln sf.write( str(s)+'\n') cn=co.find(l[i]["number"]) leco=len(cn) if leco > 1: s1=str("There are multiple contacts entered for the number") s2=str(cn) s3=s1+s2 sf.write(str(s3)+':') sf.write((l[i]["number"])+'\n') for h in range(len(cn)): q=str(h) y=str("Contact No:")+q c=cn[h] ct=c.title sf.write( y+'\n'+"Title is "+ str(ct)+'\n') # c=cn[h] for j in range(len(c)): t=c[j].type v=c[j].value lon=c[j].location lal=c[j].label tv="label is "+lal+", "+t+" : "+v+" , "+"location:h/w/o-"+lon sf.write( str(tv)+'\n') elif leco < 1: tv=str("UNKNOWN Number:")+str(l[i]["number"]) sf.write( str(tv)+'\n') elif leco ==1: dn=str(cn) # ct=cn.title # sf.write( "Title is "+ str(ct)+'\n'+cn+'\n') sf.write(dn+'\n') for h in range(len(cn)): c=cn[h] for k in range(len(c)): t=c[k].type v=c[k].value lon=c[k].location lal=c[k].label tv="label is "+lal+", "+t+" : "+v+" , "+"location:h/w/o-"+lon sf.write( str(tv)+'\n') # sf.write( str(s)+'\n') sf.close() #contacts.close() module obj has no attribute close #appuifw.note("log Written. ",'info') # medzindia.blogspot.com #Dr.MiT, Hyderabad, INDIA appuifw.note("log Written to"+fn+"\n"+"Dr.MIT....Email:imran-doc@hotmail.com,",'info') # #The advantage is that each time log is saved with the current time as filename #so no need to manually backup the file in fear of being overwritten #as when using a specific (constant/same) filename everytime, #or a loooooong file if 'append' (a) is used instead of 'write' (w). # #Dr.MiT, Hyderabad, India
Friday, May 21, 2010
Saving call logs
Subscribe to:
Posts (Atom)