HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/jid.cpython-310.pyc
o

;jJ�@szdZddlZddlZddlZddlmZddlZda	dd�Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�Zddd�ZdS)z1
Functions for creating and working with job IDs
�N)�
month_abbrcCs
tj��S)zJ
    Helper method so tests do not have to patch the built-in method.
    )�datetime�utcnow�rr�B/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/jid.py�_utc_nows
rcCsNt�}|�dd�s
|d�Strt|krttjdd�}|a|d�dt����S)z
    Generate a jid
    Z
unique_jidFz%Y%m%d%H%M%S%f�)�microseconds�_)r�get�LAST_JID_DATETIMEr�	timedelta�os�getpid)�optsZjid_dtrrr�gen_jidsrcCsbt|t�sdSt|�dkrt|�dks|ddkrdSzt|dd��WdSty0YdSw)z9
    Returns True if the passed in value is a job id
    F��r
NT)�
isinstance�str�len�int�
ValueError)�jidrrr�is_jid%s
$�rc		Cs�t|�}t|�dkrt|�dks|ddkrdS|dd�}|dd�}|dd�}|dd	�}|d	d
�}|d
d�}|dd�}d�|tt|�|||||�}|S)
zF
    Convert a salt job id into the time when the job was invoked
    rrr
�N����
��z{}, {} {} {}:{}:{}.{})rr�format�monthsr)	r�year�month�day�hour�minute�second�micro�retrrr�jid_to_time4s$�r,cCs�|�dd�t|�dg��|�dd�|�dd�|�dd	�d
�}d|vr,|�di�|d<|Sd
|vrBd|d
vrB|d
�di�|d<|S|�dg�pIgD]}t|t�rg|�d�durgd|vrg|�di�|d<|SqJ|S)z+
    Format the job instance correctly
    Zfunzunknown-function�argZtgtzunknown-targetZtgt_type�list�user�root)ZFunctionZ	ArgumentsZTargetzTarget-typeZUser�metadataZMetadata�kwargsZ	__kwarg__T)rr.r�dict)�jobr+r-rrr�format_job_instanceIs,



�	����r5cCst|�}|�dt|�i�|S)z"
    Format the jid correctly
    �	StartTime�r5�updater,�rr4r+rrr�format_jid_instanceksr:cCs t|�}|�|t|�d��|S)z4
    Format the jid correctly with jid included
    )ZJIDr6r7r9rrr�format_jid_instance_exttsr;�sha256cCsnt|t�s	t|�}tt|�tjj�|����}g}|dur"|�	|�|�
|dd�|dd�g�tjj
|�S)z1
    Return the jid_dir for the given job id
    N�)rr�getattr�hashlib�salt�utilsZstringutils�to_bytes�	hexdigest�append�extendr�path�join)rZjob_dirZ	hash_typeZjhash�partsrrr�jid_dir}s
��
rI)Nr<)�__doc__rr?r�calendarrr#Zsalt.utils.stringutilsr@rrrrr,r5r:r;rIrrrr�<module>s"