HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/at.cpython-310.pyc
o

�N�g�*�@s�dZddlZddlZddlZddlZddlZddlZddlm	Z	dZ
dZdd�Zdd	�Z
dd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�ZdS)z�
Wrapper module for at(1)

Also, a 'tag' feature has been added to more
easily tag jobs.

:platform:      linux,openbsd,freebsd

.. versionchanged:: 2017.7.0
�N)�CommandNotFoundError)�OpenBSD�FreeBSD�atcCs6tjj��stjj��rdStjj�d�durdStS)z:
    Most everything has the ability to support at(1)
    )Fz7The at module could not be loaded: unsupported platformrN)Fz7The at module could not be loaded: at command not found)�salt�utils�platformZ
is_windowsZis_sunos�path�which�__virtualname__�rr�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/at.py�__virtual__"s
rcGsHtjj�|�}|st|�d���|gt|�}td|gt|�dd�S)z.
    Wrapper to run at(1) or return None.
    z: command not foundzcmd.run_stdoutF)�python_shell)rrr	r
r�list�__salt__)�binary�args�cmdrrr
�_cmd-s
rc
Cs�g}tddkrtdd�}ntd�}|durdS|dkr d	|iSt�d
�}|��D�]&}d}tddkr@|�d�\}}|��}n�tdd
kr~|�d�rLq)|��}	d�|	dd��}
|	d}tjt	�
|
d�dd�����d�}|�|	d�|�|	d�nqtddkr�|�d�r�q)|��}	d�|	dd��}
|	d}tjt	�
|
d�dd�����d�}|�|	d�|�|	d�n3|�d�\}}|��}	d�|	dd��}
tjt	�
|
�dd�����d�}|�|	d�|�|	d�tdd|�}|��D]}|�
|�}	|	�r	|	��d}q�tdtv�rt|�}nt|�}|�r<||k�s'||k�r;|�||d|d|d|d|d��q)|�||d|d|d|d|d��q)d	|iS)z�
    List all queued and running jobs or only those with
    an optional 'tag'.

    CLI Example:

    .. code-block:: bash

        salt '*' at.atq
        salt '*' at.atq [tag]
        salt '*' at.atq [job number]
    Z	os_familyZRedHatrz-l�atqNz'at.atq' is not available.��jobsz^### SALT: (\w+)�	�osrz Rank� ���z%b %d, %Y %H:%Mr�T�rZDate�z%b %d %H:%M:%S %Z %Y�-c��)�job�date�time�queue�user�tag)�
__grains__r�re�compile�
splitlines�split�
startswith�join�datetimer'�strptime�	isoformat�append�match�groups�BSD�str�int)r*r�outputZjob_kw_regex�lineZjob_tagr%�specZspecs�tmpZtimestrZatc_outrrr
r8s�



�
�� �
�
�����rcstjj�d�s	dS�sdgdd�iStjj�����ddkr\t��dkrCtttt	d	d
�t
�d�dD����}d|�dd�i}n3tttt	dd
�t
�dD����}d|dd�i}ntttt	�fdd
�t
�dD����}d|dd�i}tdd
d�|��}|dur�dS|S)z�
    Remove jobs from the queue.

    CLI Example:

    .. code-block:: bash

        salt '*' at.atrm <jobid> <jobid> .. <jobid>
        salt '*' at.atrm all
        salt '*' at.atrm all [tag]
    rz'at.atrm' is not available.rN)Zremovedr*r�allrcS�g|]}|d�qS�r%r��.0�jrrr
�
<listcomp>��zatrm.<locals>.<listcomp>cSr@rArrBrrr
rE�rFcs$g|]}t|d��vr|d�qSrA)r9)rC�i�rrr
rE�s$z-dr)
rrr	r
�dataZ	stringify�lenr�mapr9rrr1)r�opts�retr;rrHr
�atrm�s0("���rNcOst|�dkr
dgiStjj�d�}|sdSd|vr)d�|dd�|dd	���}n	d�|dd	��}||d
g}|dd�}d
|vrG|d
|d
<td|fi|��}|d	urWdS|�d�ragdd�S|�	d�rl|�
�d}|�	d�rw|�
�d}|��d}tdt
vr�tt|��Stt|��S)a�
    Add a job to the queue.

    The 'timespec' follows the format documented in the
    at(1) manpage.

    CLI Example:

    .. code-block:: bash

        salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
        salt '*' at.at 12:05am '/sbin/reboot' tag=reboot
        salt '*' at.at '3:05am +3 days' 'bin/myscript' tag=nightly runas=jim
        salt '*' at.at '"22:02"' 'bin/myscript' tag=nightly runas=jim
    r#rrz'at.at' is not available.r*z### SALT: {}
{}rrNrF)�stdinr�runaszcmd.runzGarbled timezinvalid timespec)r�errorzwarning: commandszcommands will be executedr)rJrrr	r
�formatr1r�endswithr0r.r/r+r8rr9r:)r�kwargsrrOrZ
cmd_kwargsr;rrr
r�s2 




cCs8tddt|��}|durdS|dkrdd|�d�iS|S)	z�
    Print the at(1) script that will run for the passed job
    id. This is mostly for debugging so the output will
    just be text.

    CLI Example:

    .. code-block:: bash

        salt '*' at.atc <jobid>
    rr"Nz'at.atc' is not available.rrQzinvalid job id '�')rr9)Zjobidr;rrr
�atc#srVcKs�g}|�dd�}|�dd�}|�dd�}|�dd�}|�dd�}|�dd�}|�dd�}|r;tt|��d	kr;d
|��}t�d}	|	sFd|iS|	D]}}
|sMn||
dkrTnqH|sXn||
dkr_nqH|scnt|�d
�|
d�d�dkrsnqH|swnt|�d
�|
d�d�dkr�nqH|s�nt|�d
�|
d�d�d	kr�nqH|s�nt|�d
�|
d�d�dkr�nqH|s�n
||
d�d�dkr�nqH|�|
�qH|s�d}||d�Sd|iS)z 
    Return match jobs list
    rPNr*�hour�minute�day�month�yearr#Z20rr)Z02dr'�:rrr&�-z"No match jobs or time format error)r�note)�getrJr9rr:r/r5)rTrrPr*rWrXrYrZr[Zjobinfor%r^rrr
�_atq;sl


r`cKs|sddiStdi|��S)a%
    Check the job from queue.
    The kwargs dict include 'hour minute day month year tag runas'
    Other parameters will be ignored.

    CLI Example:

    .. code-block:: bash

        salt '*' at.jobcheck runas=jam day=13
        salt '*' at.jobcheck day=13 month=12 year=13 tag=rose
    rQzYou have given a conditionNr)r`)rTrrr
�jobcheck�sra)N)�__doc__r2r,r'Zsalt.utils.datarZsalt.utils.pathZsalt.utils.platformZsalt.exceptionsrr8rrrrrNrrVr`rarrrr
�<module>s&
29Q