
                         H   S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJr  SSK	J
r
  SSKJr  SS	KJr  SS
KJr  SSR#                  SS5      S.r\
R&                  " \
R(                  R*                  \
R(                  R,                  5       " S S\
R.                  5      5       rg)zACommand for retrieving a screenshot from the designated instance.    )absolute_import)division)unicode_literalsN)base_classes)base)flags)log)filesLCapture a screenshot (JPEG image) of the virtual machine instance's display.zx        To get a screenshot from an instance named ``{0}'', run:

          $ {1} {0} --destination=output.jpg

        ztest-instancez	{command})DESCRIPTIONEXAMPLESc                   L    \ rS rSrSr\rSr\S 5       r	S r
S rS rSS jrS	rg
)GetScreenshot,   r   Fc                 `    [         R                  R                  U SS9  U R                  SSS9  g )Nzget a screenshot from)operation_typez--destinationzBFilename, including the path, to save the screenshot (JPEG image).)help)r   INSTANCE_ARGAddArgumentadd_argument)parsers    /lib/surface/compute/instances/get_screenshot.pyArgsGetScreenshot.Args3   s<    	""6 # 8
       c                     [         R                  R                  UUR                  [         R                  " UR
                  5      S9$ )N)scope_lister)r   r   ResolveAsResource	resourcesGetInstanceZoneScopeListerclient)selfholderargss      r   _GetInstanceRefGetScreenshot._GetInstanceRef<   s@    //55fmmD 0 F Fr   c                     UR                   R                  R                  " S0 UR                  5       D6nUR                   R	                  UR                   R
                  R                  SU4/5      S   $ )NGetr    )r!   messagesComputeInstancesGetRequestAsDictMakeRequestsapitools_client	instances)r"   r#   instance_refrequests       r   _GetInstanceGetScreenshot._GetInstanceB   sm    mm$$?? !



!G==%%(E(E(O(O(-w(8 '9 ::;= =r   c                    [         R                  " U R                  5       5      nU R                  X!5      nUR                  R
                  R                  " S0 UR                  5       D6nUR                  R                  UR                  R                  R                  SU4/5      S   nSU l        UR                  S5      (       a  [        R                  " UR                  5       nUR!                  ["        R$                  " UR&                  5      5        S S S 5        UR(                  U l        UR                  U l        SU l        g UR&                  U l        g ! , (       d  f       NJ= f)Nr   r   FdestinationTr)   )r   ComputeApiHolderReleaseTrackr%   r!   r*   $ComputeInstancesGetScreenshotRequestr,   r-   r.   r/   _display_file_outputIsSpecifiedr
   BinaryFileWriterr5   writebase64	b64decodecontentsinstance_resource_name_destination_response_contents)r"   r$   r#   r0   r1   responseoutputs          r   RunGetScreenshot.RunH   s+   **4+<+<+>?F''5Lmm$$II !



!G }}))		&	&	0	0/7K+ 
H !&D&&!!$"2"23vV%%h&7&789 4(11d**d"&d  !) 1 1d
 43s   '0E
E)c                 <   U R                   (       aD  [        R                  R                  SR	                  U R
                  U R                  5      5        g [        R                  R                  R                  [        R                  " U R                  5      5        g )Nz#Output screenshot for [{}] to '{}'.)r9   r	   statusPrintformatrA   rB   sysstdoutbufferr<   r=   r>   rC   )r"   resources_were_displayeds     r   EpilogGetScreenshot.Epilog]   sg      	jj<CC


t002 3 
jjf..t/F/FGHr   )rB   r9   rA   rC   N)F)__name__
__module____qualname____firstlineno____doc___DETAILED_HELPdetailed_help_display_outputstaticmethodr   r%   r2   rF   rP   __static_attributes__r)   r   r   r   r   ,   s7    T -/   F=*Ir   r   )rV   
__future__r   r   r   r=   rL   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   ,googlecloudsdk.command_lib.compute.instancesr   googlecloudsdk.corer	   googlecloudsdk.core.utilr
   rK   rW   ReleaseTracksr7   BETAGACommandr   r)   r   r   <module>rf      s    H &  '  
 7 ( > # *
	
 F?K0 D%%**D,=,=,@,@A5IDLL 5I B5Ir   