Ë
    €Ï´  ã                   óX   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	Z	d„ Z
d	„ Zy)
z9SSH/SCP utilities for Cloud TPU Queued Resource commands.é    )Úabsolute_import)Údivision)Úunicode_literals)Ú
exceptions)ÚlogNc                 óÞ  — t        |«      }t        j                  | «      j                  «       dk(  rt	        t        |«      «      }n÷t        «       }| j                  d«      }|D ]×  }|sŒd|v r³|j                  d«      }t        |«      dk7  s
|d   r|d   s%t        j                  ddj                  |«      «      ‚t        |d   «      t        |d   «      }}||k\  r%t        j                  ddj                  |«      «      ‚|j                  t        ||dz   «      «       Œ½	 |j                  t        |«      «       ŒÙ |s%t        j                  dd
j                  | «      «      ‚t        |«      }	|	|k\  r)t        j                  ddj                  |	|dz
  «      «      ‚g }
|D ]  }|
j!                  ||   «       Œ |
S # t        $ r& t        j                  dd	j                  |«      «      ‚w xY w)z1Parses the --node flag into a list of node_specs.ÚALLÚ,Ú-é   r   é   z--nodezaRange "{}" does not match expected format "lowerBound-upperBound", where lowerBound < upperBound.z4unable to parse node ID {}. Please only use numbers.z$Unable to parse node ranges from {}.z‰node index {} is larger than the valid node indices on this TPU Queued Resource. Please only use indexes in the range [0, {}], inclusive.)ÚlenÚsixÚ	text_typeÚupperÚlistÚrangeÚsetÚsplitr   ÚInvalidArgumentExceptionÚformatÚintÚupdateÚaddÚ
ValueErrorÚmaxÚappend)Ú	node_flagÚ
node_specsÚ	num_nodesÚindexesÚrangesÚrÚboundsÚstartÚendÚmxÚfiltered_node_specsÚnodes               úClib/googlecloudsdk/command_lib/compute/tpus/queued_resources/ssh.pyÚParseNodeFlagr+      sñ  € ä*‹o€)Ü‡]]9Ó×#Ñ#Ó%¨Ò.Ü”5˜Ó#Ó$Gä‹e€GØ_‰_˜SÓ!€FÛˆÙØØ	‰Ø—‘˜“ˆÜˆv‹;˜!Ò 6¨!¢9°F¸1²IÜ×3Ñ3ØðIßIOÉØóJóð ô ˜ ™“^¤S¨°©£^ˆsˆØCŠ<Ü×3Ñ3ØðIßIOÉØóJóð ð 	‰”u˜U C¨!¡GÓ,Õ-ð	Ø
+‰+”c˜!“fÕ
ð3 ñ@ 
Ü
×
-Ñ
-ØØ.×5Ñ5°iÓ@óð ô
 ˆ7ƒ|€"Øˆ9‚_Ü
×
-Ñ
-Øð	Nç	‰I ‘MÓ	"ó	ð ð ÐÛ€dØ×Ñ˜z¨$Ñ/Õ0ð à	Ðøô3 ò 	Ü×3Ñ3ØØD×KÑKÈAÓNóð ð	ús   Ä"F=Æ=/G,c                 ó¶   — | D ]  }|j                  «        Œ |D ]=  }|sŒt        j                  j                  dj	                  |j
                  «      «       Œ? y)z›Waits for the completion of batch, but does not block for failures.

  Args:
    ssh_threads: List of ssh threads.
    nodes: List of SSH prepped nodes.
  zFinished preparing node {}.N)Újoinr   ÚstatusÚPrintr   Útpu_name)Ússh_threadsÚnodesÚ
ssh_threadr)   s       r*   ÚWaitForNodeBatchCompletionr4   X   sI   € ó  €jØ‡OOÕð  ó €dÚÜ	‡jj×ÑÐ4×;Ñ;¸D¿M¹MÓJÕKñ ó    )Ú__doc__Ú
__future__r   r   r   Úgooglecloudsdk.callioper   Úgooglecloudsdk.corer   r   r+   r4   © r5   r*   Ú<module>r;      s)   ðñ @å &Ý Ý 'å .Ý #Û 
ò;ó|Lr5   