mò &á¸Ec@s¤dZdkZdkZdklZdklZdklZedƒZdefd„ƒYZ dfd „ƒYZ d e fd „ƒYZ d e fd „ƒYZ dS(sB $Id: ProgressHandler.py 41191 2006-01-08 10:23:26Z andreasjung $ N(s getLogger(sDateTime(s InterfacetProgressHandlertIProgressHandlercBs;tZdZd„Zd„Zd„Zd„Zd„ZRS(sR A handler to log progress informations for long running operations. cCsdS(sº Called at the start of the long running process. 'ident' -- a string identifying the operation 'max' -- maximum number of objects to be processed (int) N((tidenttmax((t@/data/zmath/zope/lib/python/Products/ZCatalog/ProgressHandler.pytinitscCsdS(s Log some 'text'N((ttext((Rtinfo%scCsdS(s Called up termination N((((Rtfinish(scOsdS(s™ Called for every iteration. 'current' -- an integer representing the number of objects processed so far. N((tcurrenttargstkw((Rtreport+scCsdS(s# Log 'text' to some output channel N((R((Rtoutput2s(t__name__t __module__t__doc__RRRR R (((RRs     t StdoutHandlercBsMtZdZeZdd„Zd„Zd„Zd„Zd„Z d„Z RS(s A simple progress handler idcCs ||_dS(N(tstepstselft_steps(RR((Rt__init__;scCsE||_||_tiƒ|_ti|_ |i d|iƒdS(Ns"Process started (%d objects to go)( RRt_identRt_maxttimet_starttsyststdouttfpR (RRR((RR>s    cCs|i|ƒdS(N(RR R(RR((RREscCs"|idtiƒ|iƒdS(Ns+Process terminated. Duration: %0.2f seconds(RR RR(R((RRHscOs™|djoˆ||idjoptiƒ|i}|||i|}|id||id||it tiƒ|ƒi dƒfƒq•ndS(Nis(%d/%d (%.2f%%) Estimated termination: %sf100.0s%Y/%m/%d %H:%M:%Sh( R RRRRtseconds_so_farRt seconds_to_goR tDateTimetstrftime(RR R R RR((RR Ls  cCs|id|i|fIJdS(Ns%s: %s(RRRR(RR((RR Us( RRRRt__implements__RRRRR R (((RR6s      t ZLogHandlercBstZdZeZd„ZRS(s Use Zope loggercCsti|ƒdS(N(tLOGRR(RR((RR ^s(RRRRR!R (((RR"Ys tFilelogHandlercBs)tZdZeZdd„Zd„ZRS(s Use a custom file for logging idcCsti||ƒ||_dS(N(RRRRtfilename(RR%R((RRgscCs!t|idƒi|dƒdS(Ntas (topenRR%twriteR(RR((RR ks(RRRRR!RR (((RR$bs  ( RRRtloggingt getLoggertDateTime.DateTimeRt InterfaceR#RRR"R$( R"R#RRR*R$RR,RR((Rt?s    #