
    |!                         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\5      r " S S	\5      r	 " S
 S\5      r
 " S S\5      r " S S\5      rg)z8Messages parallel workers might send to the main thread.    )absolute_import)division)unicode_literalsNc                       \ rS rSrSrSrg)ThreadMessage   zFMessage that can be sent from multithreading workers to global status. N__name__
__module____qualname____firstlineno____doc____static_attributes__r	       9lib/googlecloudsdk/command_lib/storage/thread_messages.pyr   r      s    Nr   r   c                       \ rS rSrSrSrg)IncrementProgressMessage   z9Simple message indicating one of something has completed.r	   Nr
   r	   r   r   r   r      s    Ar   r   c                   <    \ rS rSrSr       SS jrS rS rSrg)	DetailedProgressMessage!   a  Message class for sending information about operation progress.

This class contains specific information on the progress of operating on a
file, cloud object, or single component.

Attributes:
  offset (int): Start of byte range to start operation at.
  length (int): Total size of file or component in bytes.
  current_byte (int): Index of byte being operated on.
  finished (bool): Indicates if the operation is complete.
  time (float): When message was created (seconds since epoch).
  source_url (StorageUrl): Represents source of data used by operation.
  destination_url (StorageUrl|None): Represents destination of data used by
    operation. None for unary operations like hashing.
  component_number (int|None): If a multipart operation, indicates the
    component number.
  total_components (int|None): If a multipart operation, indicates the
    total number of components.
  operation_name (task_status.OperationName|None): Name of the operation
    running on target data.
  error_occurred (bool): Indicates if an error occurred during the
    operation.
  process_id (int|None): Identifies process that produced the instance of this
    message (overridable for testing).
  thread_id (int|None): Identifies thread that produced the instance of this
    message (overridable for testing).
Nc                    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        U=(       d    [        R                  " 5       U l        U=(       d    [        R                  " 5       R                  U l        g)zFInitializes a ProgressMessage. See attributes docstring for arguments.N)offsetlengthcurrent_bytetime
source_urldestination_urlcomponent_numbertotal_componentsoperation_nameerror_occurredosgetpid
process_id	threadingcurrent_threadident	thread_id)selfr   r   r   r   r   r   r    r!   r"   r#   r&   r*   s                r   __init__ DetailedProgressMessage.__init__>   si      KK$I O*,,(( /BIIKDOB)":":"<"B"BDNr   c                 t    [        XR                  5      (       d  [        $ U R                  UR                  :H  $ N
isinstance	__class__NotImplemented__dict__r+   others     r   __eq__DetailedProgressMessage.__eq__]   *    e^^,,==ENN**r   c                    SR                  U R                  5      nU R                  (       a  SR                  U R                  5      OSnU R                  (       a%  SR                  U R                  R                  5      OSnSR                  U R
                  R                  U R                  U R                  U R                  U R                  UUU R                  U R                  UU R                  U R                  U R                  S9$ );Returns a string with a valid constructor for this message.'{}'NaP  {class_name}(time={time}, offset={offset}, length={length}, current_byte={current_byte}, source_url={source_url}, destination_url={destination_url}, component_number={component_number}, total_components={total_components}, operation_name={operation_name}, error_occurred={error_occurred}, process_id={process_id}, thread_id={thread_id}))
class_namer   r   r   r   r   r   r    r!   r"   r#   r&   r*   )formatr   r   r"   valuer2   r   r   r   r   r   r    r!   r#   r&   r*   )r+   source_url_stringdestination_url_stringoperation_name_strings       r   __repr__ DetailedProgressMessage.__repr__b   s    doo6/3/C/Cd**+ 
  	d))//0 	" f>>**YY{{{{&&$.....,**??..  r   )r    r   r   r#   r   r   r"   r&   r   r*   r   r!   )NNNNFNN	r   r   r   r   r   r,   r7   rC   r   r	   r   r   r   r   !   s/    D  $ $ $"#C>+
!r   r   c                   2    \ rS rSrSr  SS jrS rS rSrg)	ManifestMessage   aG  Message class for updating manifest file with result of copy.

Attributes:
  source_url (StorageUrl): Source URL. Used to match information recorded by
    copy progress infra (FilesAndBytesStatusTracker).
  destination_url (StorageUrl): Destination URL.
  end_time (datetime): Date and time copy completed.
  size (int): Size of file or object.
  result_status (manifest_utils.ResultStatus): End status of copy. Either
    "OK", "skip", or "error".
  md5_hash (str|None): Hash of copied file or object.
  description (str|None): Message about something that happened during a copy.
Nc                 X    Xl         X l        X0l        X@l        XPl        X`l        Xpl        g)z:Initializes ManifestMessage. Args in attributes docstring.N)r   r   end_timesizeresult_statusmd5_hashdescription)r+   r   r   rJ   rK   rL   rM   rN   s           r   r,   ManifestMessage.__init__   s*     !O*MI&M"r   c                    SR                  U R                  5      nSR                  U R                  5      nSR                  U R                  5      nU R                  (       a  SR                  U R                  5      OSnU R
                  (       a  SR                  U R
                  5      OSnSR                  U R                  R                  UUUU R                  U R                  UUS9$ )r;   r<   Nonez{class_name}(source_url={source_url}, destination_url={destination_url}, end_time={end_time}, size={size}, result_status={result_status}, md5_hash={md5_hash}, description={description}))r=   r   r   rJ   rK   rL   rM   rN   )
r>   r   r   rJ   rM   rN   r2   r   rK   rL   )r+   r@   rA   end_time_stringmd5_hash_stringdescription_strings         r   rC   ManifestMessage.__repr__   s    doo6#]]4+?+?@mmDMM2O6:mmfmmDMM2O!--  39 ? AG>>22, 6(YY"00(. AG A00r   c                    [        U[        U 5      5      (       d  [        $ U R                  UR                  :H  =(       a    U R                  UR                  :H  =(       a    U R
                  UR
                  :H  =(       ay    U R                  UR                  :H  =(       aY    U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ r/   )
r1   typer3   r   r   rJ   rK   rL   rM   rN   r5   s     r   r7   ManifestMessage.__eq__   s    eT$Z((OOu/// 2  E$9$992MMU^^+204		UZZ0G2 %"5"552 MMU^^+	2
  1 113r   )rN   r   rJ   rM   rL   rK   r   )NN)	r   r   r   r   r   r,   rC   r7   r   r	   r   r   rG   rG      s    ( #"0*3r   rG   c                   .    \ rS rSrSrSS jrS rS rSrg)	WorkloadEstimatorMessage   zMessage class for estimating total workload of operation.

Attributes:
  item_count (int): Number of items to add to workload estimation.
  size (int|None): Number of bytes to add to workload estimation.
Nc                     Xl         X l        g)zCInitializes WorkloadEstimatorMessage. Args in attributes docstring.N
item_countrK   )r+   r^   rK   s      r   r,   !WorkloadEstimatorMessage.__init__   s     !OIr   c                 t    [        XR                  5      (       d  [        $ U R                  UR                  :H  $ r/   r0   r5   s     r   r7   WorkloadEstimatorMessage.__eq__   r9   r   c                 t    SR                  U R                  R                  U R                  U R                  S9$ )r;   z2{class_name}(item_count={item_count}, size={size}))r=   r^   rK   )r>   r2   r   r^   rK   )r+   s    r   rC   !WorkloadEstimatorMessage.__repr__   s6    ?FF>>**??YY G  r   r]   r/   rE   r	   r   r   rZ   rZ      s    +
r   rZ   )r   
__future__r   r   r   r$   r'   objectr   r   r   rG   rZ   r	   r   r   <module>rf      s]    ? &  ' 	 OF OB} Bbm bJ=3m =3@} r   