ó i'dWc@sDdZddlZddlZddlZdefd„ƒYZdS(s,Progress monitor for the transfer checkpointiÿÿÿÿNt ProgressMoncBsVeZdZddddd dd„Zddd„Zdd„Zd„Zd „ZRS( s[The ProgressMon class contains methods to monitor the progress of the transfer. igà?cCsL||_||_||_||_||_||_d|_t|_ dS(N( t distrosizetinitpcttendpcttdonetloggert sleep_fortNonetthread1tFalsetprog_init_completed(tselfRRRRRR((sprog.pyt__init__%s       idcCss||_||_||_t|_tjd|jd|fƒ|_|jj ƒx|j snt j dƒqUWdS(sQStart a thread to monitor the progress populating a file system. Input: filesys - file system to monitor distrosize - full distro size in kilobytes initpct - base percent value from which to start calculating endpct - percentage value at which to stop calculating ttargettargsgà?N( RRRR Rt threadingtThreadt_ProgressMon__progressthreadRtstartR ttimetsleep(R tfilesysRRR((sprog.pyt startmonitor0s      ixcCs6|jj|ƒ|jjƒr2|jjdƒndS(sEWait until the thread whose join() method is called terminates. Input: timeout - number of second to wait for the thread to terminate. If it is desired to block until the thread terminates, timeout=None should be used. s-Progress monitoring thread is not terminated.N(RtjointisAliveRtdebug(R ttimeout((sprog.pytwaitBs cCsDy,tj|ƒ}|j|j|jdSWntk r?nXdS(s±Find the current size of the specified file system. Input: filesystem - filesystem to find size of. Returns: size of the filesystem in kilobytes. iN(toststatvfstf_blockstf_bfreetf_frsizetOSError(R t filesystemtstat((sprog.pyt__fssizeQs  c Csud}y&x|dkr*|j|ƒ}q WWn"tk rP}t|_|‚nX|j|j}d}t|_xþtrp|jr†dStj |j ƒ|j|ƒ}|dkr·qsn||}|dkrÓqsn|d|j }|||j |j} | |jks|dkr#|j} n| |krQ|j j dt| ƒƒ| }n| |jksi|jrsdSqsWdS(svMonitor the progress in populating the file system. Input: filesystem - the file system to monitor iÿÿÿÿNiidsTransferring contents(Rt_ProgressMon__fssizet ExceptiontTrueR RRRRRRRRtreport_progresstint( R R"tinitsizetexttotpcttprevpcttfssztfsgaint actualpcttpct((sprog.pyt__progressthread]s:           N( t__name__t __module__t__doc__RR RRR%R(((sprog.pyR!s   (R5RRRtobjectR(((sprog.pyts