ó J”Vc@s"ddlZddlZddlZddlZddlZddlTddlTddlmZm Z m Z yddl m Z Wn=e k ræejdƒsĄejdƒejdƒqĄnXdZd Zd Zd Zd Zd Zd eZdeZddd„ƒYZddd„ƒYZdS(i’’’’N(t*(tdevicetutilstexifi(tpcardextt HPLIP_BUILDs>PCARDEXT could not be loaded. Please check HPLIP installation.iiii iiit PhotoCardFilecBsDeZdd„Zd„Zdd„Zd„Zd„Zd„ZRS(cCs„d|_t|_d|_||_tjdƒ|_|dk rR|j|ƒnt |_ |jj t j |jd|j ƒƒdS(Nitc(tpostTruetclosedt file_sizetpctarraytbuffertNonetopentINITIAL_PCARDFILE_BUFFERt buffer_sizet fromstringRtreadtname(tselfR R((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt__init__:s      cCst|_||_dS(N(tFalseR R(RR((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRHs icCs]|dkr||_nA|dkr6|j|7_n#|dkrU|j||_ndSdS(Niii(RR (Rtoffsettwhence((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pytseekLs    cCs|jS(N(R(R((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyttellWscCsŗ|dkr¶|j||jkrU|j|j|j|!jƒ}|j|7_|SxN|j||jkr„|jjtj|j|jtƒƒ|jt7_qXW|j|ƒSndS(Ni( RRRttostringRRRRtINCREMENTAL_PCARDFILE_BUFFER(Rtsizetdata((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR[s  %cCst|_d|_dS(Ni(R R R(R((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pytcloseis N( t__name__t __module__RRRRRRR!(((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR7s     t PhotoCardcBsÖeZd-d-d-d„Zdd„Zded„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zeded„Zd„Zd„Zd„Zd„Zd„Zd„Zed„Zd-d-d„Zd-d-d„Zd„Zd-d-ed„Zd„Zd-d-d„Zd„Z ed„Z!ed„Z"eed „Z#d!„Z$d"„Z%d#„Z&ed$„Z'd%„Z(d-d&„Z)d'„Z*d(„Z+d)„Z,d*„Z-d+„Z.d,„Z/RS(.cCsæ|dkr:tj||ƒ|_|jjƒt|_n||_t|_tjƒ|_ g|_ |jj |_ t|_ g|_ i|_i|_t|_t|_d|_t|_dS(N(RRtDeviceRR t close_deviceRRtStackt dir_stackt current_dirt device_urit pcard_mountedt saved_pwdt sector_buffertsector_buffer_countst cache_flagt write_protecttcallbacktchannel_opened(Rtdev_objR*t printer_name((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRps"             tcCsdS(N((RR((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pytSTART_OPERATION‰scCs |jr|r|jƒndS(N(R2t close_channel(RRtflag((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt END_OPERATIONŒscCs ||_dS(N(R1(RR1((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt set_callbackscCsitjd||fƒ|jrćxĄt|||ƒD]}||jkr4Pq4q4Wd}x‚t|||ƒD]m}dj||j|gƒ}tjd|ƒ|j|}|d|j|<|jdk rk|jƒqkqkW|Sn|jdk r’|jƒn|j s|j ƒntjd||fƒt t|||ƒƒ}t j dd|t||Œ}|jdk r|jƒn|jj|ƒ}tjd|ƒ|jjd ƒ} t jd | ƒd } tjd | ƒ| d krP|jjdƒ} t jd| ƒ\} } tjd| | | fƒdd |t}} }xc| |krŖ|jj|ƒ} | t| ƒ7} dj|| gƒ}|jdk rH|jƒqHqHW|jrLd }xt||| ƒD]j}|||t!|j|<|jj|d ƒ}|d|j|<|t7}|jdk rĪ|jƒqĪqĪW|j|ƒn|Stjd| ƒdSdS(Ns%read pcard sector: sector=%d count=%dR5sCached sector read sector=%dis%Normal sector read sector=%d count=%ds!HHtIs%d bytes writtenis!HisReturn code: %xiis!IHscode=0x%x, nsector=%d, ver=%dsError code: %d(tlogtdebugR/trangeR-tjoinR.R1RR2t open_channeltlisttstructtpacktREAD_CMDRt writePCardt readPCardtunpackt SECTOR_SIZEtlentgett _check_cacheterror(RtsectortnsectortsRtcounttsectors_to_readtrequestt bytes_writtenR tcodet nsector_readtvert data_readt total_to_readti((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt_read“sh          c Cstjd||t|ƒfƒ|js6|jƒntt|||ƒƒ}tjdd|t |d|Œ}dj ||gƒ}|j dk r£|j ƒn|j j|ƒ|j jdƒ}|j dk rį|j ƒntjd|ƒd}|tkr |jrœd}x[t|||ƒD]F} tjd|ƒ|||t!|j| RBRCt WRITE_CMDR?R1RRRERFRGtNAKR/RHR-R.RKtKeyErrorRLR7( RRMRNRtsectors_to_writeRRR RTRYRO((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt_writeésF   #            cCsŖt|jƒtkr¦t|jjƒƒd}}xq|D]f}|j|dkr9|j|=|j|=|d7}||kr€Pn|jdk rŸ|jƒqŸq9q9WndS(Nii(RIR-t MAX_CACHERAtkeysR.R1R(RRNtttnRO((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRKs     cCs|jS(N(R.(R((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt cache_info/scCs|jj|dƒS(Ni(R.RJ(RRM((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt cache_check2scCs#||_|js|jƒndS(N(R/t cache_reset(Rtcontrol((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt cache_control5s  cCs|jS(N(R/(R((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt cache_state;scCs|jjƒ|jjƒdS(N(R-tclearR.(R((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRf>s cCs8d}|jdƒztjƒ}Wd|jdƒ|SX(Nitdf(R6RRkR9(RRk((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRkBs   RcCsŅ|sd}n|rL|jdƒztjƒ|_Wd|jd|ƒXng|jD]$\}}}|jƒ||f^qV|_|dkr–|jSg|jƒjƒjƒD]}tj |j|ƒ^qÆdS(NRtlsi( R6RRlR)R9tlowertstriptsplittfnmatchtfilter(Rt force_readt glob_listt opencloseRctaROtx((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRlKs  7 cCs3x,|jD]!}||kr |j|dSq WdS(Nii(R)(RRtf((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR\s cCs*g|jD]}|ddkr |^q S(Nitd(R)(RRv((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt current_filesbscCs*g|jD]}|ddkr |^q S(NiRx(R)(RRv((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pytcurrent_directoriesescCsrt|ƒdkrng|jƒD]}|d^q}g|jƒjƒjƒD]}tj||ƒ^qNdSgS(Ni(RIRyRnRmRoRpRq(RRsRvRy((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt match_fileshs#9cCsrt|ƒdkrng|jƒD]}|d^q}g|jƒjƒjƒD]}tj||ƒ^qNdSgS(Ni(RIRzRnRmRoRpRq(RRsRvt current_dirs((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt match_dirsns#9cCs'tj|ƒd}|dkr#dS|S(Nisunknown/unknown(t mimetypest guess_typeR(RtfilenameRb((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt classify_filets cCs`|jdƒd}z5t|dƒ}tj||jƒƒ}|jƒWd|jd|ƒ|SX(Ntcpitw(R6RRR‚tfilenoR!R9(RRt local_fileRtttotalRw((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR‚{s c Csddf\}}|jdƒtjƒ}z£x†|D]~}|j||tƒ} |r“|tjj|jƒ|ƒtjjtjƒ|ƒ| ƒn|| 7}|r³t j |ƒnq5Wtjƒ} | |}Wd|rķ|j t dtƒn|j dƒ||fSX(Nit cp_multipleR(R6ttimeR‚RtostpathR?tpwdtgetcwdRtrmRlR R9( Rtfilelisttremove_after_copytcp_status_callbacktrm_status_callbacktdeltaR†tt1RwRtt2((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR‡‡s"   =   cCs^|jƒddf\}}|jdƒtjƒ}zxē|D]ß}|jdƒd } |jdƒd} x| D]} |j| tƒqrW|j| | tƒ} |tk rÕ||tj j tj ƒ| ƒ| ƒn|| 7}|rt j | ƒ|tk r ||ƒnn|jdtƒq?Wtjƒ} | |}Wd|jƒ|jdƒ||fSX(Nitcp_listt/i’’’’(tsave_wdR6RˆRotcdRR‚RR‰RŠR?RŒRRt restore_wdR9(RRŽRRR‘R’R†R“Rwt path_listR€tpRR”((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR•¢s0      (      cCs>d}|jdƒztj||ƒ}Wd|jdƒ|SX(Nitcp_fd(R6RR‚R9(RRtfdR†((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRœŹs   cCs¶t}|jƒ|jdƒd}tjƒ}x:|D]2}|s6|\} } } } | jdƒ} | d }| d}|jdtƒ|dk rÜ|tjj |j ƒ|ƒtjj tj ƒ|ƒdƒrÜt }PqÜnt |ƒdkrx!|D]}|j|tƒqõWntjjtjj tj ƒ|ƒƒr­d}xGt rˆtjjtjj tj ƒ|d|ƒƒs{Pn|d7}qBW||j||d|tƒ7}n||j||tƒ7}|dk r|tjj |j ƒ|ƒtjj tj ƒ|ƒ| ƒrt }Pqn|sh|dk rO|tjj |j ƒ|ƒƒn|j|ttƒqhq6q6Wtjƒ}|jtƒ|jt dtƒ|jdƒ||||fS( NtunloadiR–i’’’’is (%d)iR(RR—R6RˆRoR˜RR‰RŠR?R‹RŒR RItexistsR‚RR™RlR9(Rt unload_listRR‘t dont_removet was_cancelledR†R“RwRRttyptsubtypR›tdirsR€RxRYR”((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRžŌsT       ! ' /$ ! "   cCs|jƒ}|j|ƒS(N(ttreet_PhotoCard__build_unload_list(RR¦((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pytget_unload_lists c Cs÷|dkr!g}tjƒ}nxĻ|D]Ē}t||ƒtiƒkr{|j|ƒ|j||||ƒ|jƒq(|j|ƒjdƒ\}}|dkr(|j ƒ}dj dj |ƒ|gƒ}|j |||||fƒq(q(W|S(NR–timagetaudiotvideo(R©RŖR«( RRR'ttypetpushR§tpopRRotas_listR?tappend( RR¦RŠtoutRxR£R¤R›R((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyt__build_unload_lists      $cCs tjƒS(N(Rtinfo(R((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR³)scCs |jdƒz{tj|ƒ}|r‡|dkrA|jjƒn0|jdƒ}x|D]}|jj|ƒqWW|jtdt ƒnWd|j d|ƒXdS(NR˜R–R( R6RR˜R(RjRoR­RlR RR9(RR„RttstatRx((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR˜-s   cCsØt|jjƒƒdkr+|jd|ƒS|jjƒ|jdƒzKtjdƒx$|jjƒD]}tj|ƒqeW|jtdt ƒWd|j d|ƒXdS(NiR–tcdupR( RIR(RÆR˜R®R6RRlR RR9(RRtRx((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRµ@s   cCsN|jƒz/tj|ƒ}|r8|jtdtƒnWd|j|ƒ|SX(NR(R6RRRlR RR9(RRt refresh_dirRttr((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRPs  cCsätjdƒ|jdƒz©tj|j|jƒ}tjƒ}|d|_tjd|ƒ|dkr­|jr|j ƒnt |_ tj dƒ|j t dtƒnt|_ ttƒ‚Wd|j rß|jdƒnXdS(NsMounting photocard...tmountisstat=%diR–R(R<R=R6RRøRZR_R³R0R@R R+R˜RlRtErrort'ERROR_DEVICE_DOES_NOT_SUPPORT_OPERATIONR9(RR“t disk_info((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyRø[s"           cCsddj|jjƒƒS(NR–(R?R(RÆ(R((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR‹yscCs|jjƒ|_dS(N(R(RÆR,(R((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR—}scCs8|jd|ƒx!|jD]}|j||ƒqWdS(NR–(R˜R,(RRtRx((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR™€scCsO|jdƒi}z'|jƒ|jƒ}|jtƒWd|jdƒ|SX(NR¦(R6R—t_PhotoCard__treeR™RR9(Rtdir_tree((s_/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/pcard/photocard.pyR¦†s    cCs×|dkr"i}tjdƒnx®tjƒD] }|djƒ}|jdk ra|jƒn|dkr/|ddkr¾|j|tƒi||<|j||ƒ||<|jtƒqĻ|d||s.           7