
                         d    S r SSKJr  SSKJr  SSKJr  SSKrSSKJr   " S S5      rS	 r	SS
 jr
g)z8Messages parallel workers might send to the main thread.    )absolute_import)division)unicode_literalsN)thread_messagesc                   8    \ rS rSrSr      SS jrSS jrSrg)	FilesAndBytesProgressCallback   a  Tracks file count and bytes progress info for large file operations.

Information is sent to the status_queue, which will print aggregate it
for printing to the user. Useful for heavy operations like copy or hash.
Arguments similar to thread_messages.ProgressMessage.
Nc                 |    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        g)ae  Initializes callback, saving non-changing variables.

Args:
  status_queue (multiprocessing.Queue): Where to submit progress messages.
    If we spawn new worker processes, they will lose their reference to the
    correct version of this queue if we don't package it here.
  offset (int): Start of byte range to start operation at.
  length (int): Total size of file or component in bytes.
  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.
  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).
N)
_status_queue_offset_length_source_url_destination_url_component_number_total_components_operation_name_process_id
_thread_id)selfstatus_queueoffsetlength
source_urldestination_urlcomponent_numbertotal_componentsoperation_name
process_id	thread_ids              <lib/googlecloudsdk/command_lib/storage/progress_callbacks.py__init__&FilesAndBytesProgressCallback.__init__"   s>    B &LL!+--)!O    c                 T   A[         R                   " 5       nU R                  R                  [        R                  " U R
                  U R                  UUU R                  U R                  U R                  U R                  U R                  UU R                  U R                  S95        g)zSends operation progress information to global status queue.

Args:
  current_byte (int): Index of byte being operated on.
  error_occurred (bool): Whether an error occurred during the
    operation.
  *args (list[any]): Unused.
)r   r   current_bytetimer   r   r   r   r   error_occurredr   r   N)r&   r   putr   DetailedProgressMessager   r   r   r   r   r   r   r   r   )r   r%   r'   argscurrent_times        r    __call__&FilesAndBytesProgressCallback.__call__N   s     	 99;L//<<<<%'' 11!33!33//)''oo	'(r#   )
r   r   r   r   r   r   r   r   r   r   )NNNNNN)F)__name__
__module____qualname____firstlineno____doc__r!   r,   __static_attributes__ r#   r    r   r      s&      $ $ $"* X(r#   r   c                 L    U R                  [        R                  " 5       5        g N)r(   r   IncrementProgressMessage)r   s    r    increment_count_callbackr8   k   s    ?;;=>r#   c                 J    U R                  [        R                  " XS95        g)a  Tracks expected item count and bytes for large operations.

Information is sent to the status_queue, which will aggregate it
for printing to the user. Useful for heavy operations like copy. For example,
this sets the "100" in "copied 5/100 files."
Arguments similar to thread_messages.WorkloadEstimatorMessage.

Args:
  status_queue (multiprocessing.Queue): Reference to global queue.
  item_count (int): Number of items to add to workload estimation.
  size (int|None): Number of bytes to add to workload estimation.
)
item_countsizeN)r(   r   WorkloadEstimatorMessage)r   r:   r;   s      r    workload_estimator_callbackr=   o   s#     ..,-r#   r6   )r2   
__future__r   r   r   r&   "googlecloudsdk.command_lib.storager   r   r8   r=   r4   r#   r    <module>r@      s0    ? &  '  >N( N(b?-r#   