
    3
                     j    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KJr  SSK	J
r
  S	 rS
 rS rg)z%Utility functions for task execution.    )absolute_import)division)unicode_literalsN)errors)optimize_parameters_util)
propertiesc                 N    U  H  nXR                   L d  M  UR                  s  $    g)zFGets first item with matching topic from list of task output messages.N)topicpayload)messagesr
   messages      9lib/googlecloudsdk/command_lib/storage/tasks/task_util.py"get_first_matching_message_payloadr      s%    g__  
    c                     [         R                  R                  R                  R	                  5       n [         R                  R                  R
                  R	                  5       nU b  Uc  [        R                  $ U S:  =(       d    US:  $ )a"  Checks execution settings to determine if parallelism should be used.

This function is called in some tasks to determine how they are being
executed, and should include as many of the relevant conditions as possible.

Returns:
  True if parallel execution should be used, False otherwise.
   )r   VALUESstorageprocess_countGetIntthread_countr   DEFAULT_TO_PARALLELISM)r   r   s     r   should_use_parallelismr   $   sr     ##++99@@B-""**77>>@,l2 $:::			.lQ..r   c                     [         R                  R                  S:  d<  [         R                  R                  S:X  a  [         R                  R                  S:  ao  [        R
                  " SR                  [         R                  R                  [         R                  R                  [         R                  R                  5      5      egg)zwTask execution assumes Python versions >=3.5.

Raises:
  InvalidPythonVersionError: if the Python version is not 3.5+.
      z]This functionality does not support Python {}.{}.{}. Please upgrade to Python 3.5 or greater.N)sysversion_infomajorminorr   InvalidPythonVersionErrorformatmicro r   r   require_python_3_5r%   7   s     	aC$4$4$:$:a$?$'$4$4$:$:Q$>

*
*	$$*F""""""%
  %? %@r   )__doc__
__future__r   r   r   r   "googlecloudsdk.command_lib.storager   r   googlecloudsdk.corer   r   r   r%   r$   r   r   <module>r*      s.    , &  ' 
 5 G */&r   