+
    Ci                     T   ^ RI t  ^ RIHtHt ^ RIt^ RIt^ RIt^ RIt^ RI	t
^ RIt
 ^ RIHt ^ RIt ! R R] P                   4      t]R8X  Ed1   ]
P&                  P)                  4       t]P+                  ]
P,                  P/                  4       4       ]P0                  ! R4      t]P5                  4       P7                  4       t] P:                  ! 4       t]P?                  4        R]P@                  PB                  : R	]P@                  PD                  ^ ,          PB                  : R
]: R2t#]! ]$! ]P@                  PJ                  PM                  4       4      ]#] P:                  ! 4       ]4      t']'PQ                  4        R# R#   ] d    ^ RIHtHt  ELi ; i  ] d    ^ RIHt  ELyi ; i)    N)EmptyQueue)urlopenc                      a  ] tR t^t o Rt ! R R]P                  4      tRR ltR t	RR lt
R tRR	 ltRR
 ltR tRtV tR# )
MirrorTestz@Determines the best mirrors by perfoming ping and download test.c                   4   a  ] tR t^t o RtRR ltR tRtV tR# )MirrorTest.PingWorkerzUse the command line command ping to determine the server's
response time. Using multiple threads allows to run several
test simultaneously.c                    WPn         W`n        W@n        W0n        Wn        W n        \        P                  ! R 4      V n        \        P                  P                  V 4       R# )z^rtt .* = [\.\d]+/([\.\d]+)/.*N)bordersmodparentidjobsresultsrecompilematch_result	threadingThread__init__)selfr   r   r   r   r   r   s   &&&&&&&?/usr/lib/python3/dist-packages/softwareproperties/MirrorTest.pyr   MirrorTest.PingWorker.__init__   sF    "LH KGI"L "

+L MD%%d+    c                n   R pV P                   P                  4       '       Eg   V P                  P                  P	                  4       '       Ed    V P                   P                  R4      pVP                  pV P                  P                  RV,          4       \        P                  ! RRRRRV.\        P                  \        P                  RR	7      P                  p VP                  4       pV'       g   M#\        P                  ! V P                   V4      pK=  \$        P&                  P)                  4        \$        ;P*                  ^,          un        V P                  P-                  \$        P*                  \$        P.                  V P0                  V P2                  4       V'       d/   V P4                  P7                  \9        V^ ,          4      VX.4       \$        P&                  P;                  4        EK  R # R #   \"         d     R #  T P                  P                  R
X,          4        EL; i)NFzPinging %s...pingz-qz-c 2z-W 1z-i 0.5T)stdoutstderruniversal_newlineszSkipping %s)r   emptyr   runningisSetgethostnamereport_action
subprocessPopenPIPESTDOUTr   readliner   findallr   r   r   completed_lockacquire	completedreport_progresstodor   r   r   appendfloatrelease)r   resultmirrorhostcommandolines   &     r   runMirrorTest.PingWorker.run#   s   Fiioo''DKK,?,?,E,E,G,GD!YY]]51F!??DKK--o.DE)//vvxY]0^7A7A7H7HCG I JP  '002#!!#D,=,=t!D ))113$$)$++J,@,@,6OO,0LL,0HH6 LL''vay)94(HI))1139 -H'  DKK--md.BCs   B'H  9#H   H4#H4)r   r   r   r   r   r   r   N)r      r   r   )	__name__
__module____qualname____firstlineno____doc__r   r9   __static_attributes____classdictcell____classdict__s   @r   
PingWorkerr	      s     	#	,	4 	4r   rG   Nc                n   \         P                  P                  V 4       R V n        RV n        W0n        RV n        W n        . V n        ^ \        n
        \         P                  ! 4       \        n        \        V4      \        n        Wn        V'       g   \         P                   ! 4       V n        R# W@n        R# ) N)r   r   g        )r   r   r   actionprogresseventbest	test_filethreadsr   r.   Lockr,   lenr0   mirrorsEventr!   )r   rR   rN   rL   r!   s   &&&&&r   r   MirrorTest.__init__C   sy    !!$'#
	" 
$-NN$4
!g,
$??,DL"Lr   c                n    Wn         V P                  '       d   V P                  P                  4        R # R # N)rJ   rL   set)r   texts   &&r   r%   MirrorTest.report_actionT   s#    :::JJNN r   c                   W^ ,          ,           W$^,          ,           V^ ,          V^,          V^ ,          ,
          V,          V,          ,           3V n         V P                  '       d   V P                  P                  4        R# R# )zISubclasses should override this method to receive
progress status updatesN)rK   rL   rW   )r   currentmaxr   r   s   &&&&&r   r/   MirrorTest.report_progressY   sb     !q6)1v wqzGAJ'>#&E&OOQ :::JJNN r   c           
        V P                  ^RRR7      p\        V P                  4      pV^8  d   VP                  ^ ^ V P                  \        P
                  ! ^V^,
          4      ,          .4       VP                  ^ ^ V P                  \        P
                  ! ^V^,
          4      ,          .4       T P                  V Uu. uF  q3^,          NK  	  upR	\        P                  \        P                  3R7      pV F"  w  rV\        RVP                  : RV: 24       K$  	  V'       g   R# V^ ,          ^,          P                  p\        RV,          4       V# u upi )
   )r\   r   r   )r   r   zmirror: z	 - time: Nzand the winner is: %s)r         ?)r      r`   r<   )run_ping_testrQ   rR   r1   randomrandintrun_download_testr   r0   printr$   )r   results_pingsizerr   thwinners   &       r   run_full_testMirrorTest.run_full_testb   s   ))au)M4<< !8At||FNN1d1f4M'N OPAt||FNN1d1f4M'N OP(()E1A$$)E19.8oo.8oo.? ) @ FQQZZ;< QZ]++F)F23M *Fs   Ec           	        VR8X  d   V P                   p\        4       pV F  pVP                  V4       K  	  . p\        ^4       FE  p\        P                  WWWW44      p	V P                  P                  V	4       V	P                  4        KG  	  V P                   F  p	V	P                  4        K  	  VP                  4        V^ V # )zPerforms ping tests of the given mirrors and returns the
best results (specified by max).
Mod and borders could be used to tweak the reported result if
the download test is only a part of a whole series of tests.N)rR   r   putranger   rG   rO   r1   startjoinsort)
r   rR   r\   r   r   r   mr   irk   s
   &&&&&     r   rc   MirrorTest.run_ping_testw   s    
 d?llGwAHHQK rA%%dQgKALL"GGI 
 AFFH  	q~r   c                b  a  V 3R lpVR8X  d   S P                   p. pV Fy  pS P                  P                  4       '       g    MXV! V4      pV^ 8  d   VP                  W.4       S P	                  VP                  V4      ^,           \        V4      RV4       K{  	  VP                  4        V^ V # )zPerforms download tests of the given mirrors and returns the
best results (specified by max).
Mod and borders could be used to tweak the reported result if
the download test is only a part of a whole series of tests.c                 0  < V P                  4       ^ ,          : RSP                  : 2pSP                  RV,          4       \        P                  ! 4       p \	        V^R7      P                  R4       \        P                  ! 4       V,
          #     ^ # ; i)r   /zDownloading %s...)timeouti  )get_repo_urlsrN   r%   timer   read)r5   urlrs   r   s   &  r   test_download_speed9MirrorTest.run_download_test.<locals>.test_download_speed   sy    #113A66!^^-C2S89IIKEQ',,V4yy{U**s   7B BNrb   )rR   r!   r"   r1   r/   indexrQ   ru   )	r   rR   r\   r   r   r   r   rv   download_times	   f&&&&    r   rf   MirrorTest.run_download_test   s    		 d?llGA<<%%''/2Mq 12  q!1A!5s7|XsS  	q~r   c                d    V P                  4       V n        V P                  P                  4        R# )z/Complete test exercise, set self.best when doneN)rn   rM   r!   clear)r   s   &r   r9   MirrorTest.run   s"    &&(	r   )rJ   rM   rL   rR   rK   r!   rN   rO   rV   ))r   d   r=   )NNr;   r=   )r>   r?   r@   rA   rB   r   r   rG   r   r%   r/   rn   rc   rf   r9   rC   rD   rE   s   @r   r   r      sC     J+4Y%% +4Z#"
*.< r   r   __main__zdpkg --print-architecturezdists/r{   z/binary-z/Packages.gz))r   queuer   r   ImportErrorr~   r   r&   osaptsources.distro
aptsourcesaptsources.sourceslisturllib.requestr   urllib2rd   r   r   r>   distro
get_distroget_sourcessourceslistSourcesListpopenpiper   striparchrS   r!   rW   source_templatename
componentsrN   list
mirror_setvaluesapprn    r   r   <module>r      sc   #"  	  	   & [!! [z z))+F
z--99;<88/0D99;DooGKKM'',,''2215::I T&00;;BBDE	 17<C W  #""#    s"   F  F  FFF'&F'