HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/jid.cpython-310.pyc
o

�N�g��@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
|vr@d|d
vr@|d
�di�|d<|S)z+
    Format the job instance correctly
    Zfunzunknown-function�argZtgtzunknown-targetZtgt_type�list�user�root)ZFunctionZ	ArgumentsZTargetzTarget-typeZUser�metadataZMetadata�kwargs)rr.)�jobr+rrr�format_job_instanceIs



�	�r4cCst|�}|�dt|�i�|S)z"
    Format the jid correctly
    �	StartTime�r4�updater,�rr3r+rrr�format_jid_instance_sr9cCs t|�}|�|t|�d��|S)z4
    Format the jid correctly with jid included
    )ZJIDr5r6r8rrr�format_jid_instance_exthsr:�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_dirqs
��
rH)Nr;)�__doc__rr>r�calendarrr#Zsalt.utils.stringutilsr?rrrrr,r4r9r:rHrrrr�<module>s