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__/apcups.cpython-310.pyc
o

�N�g��@sndZddlZddlmmZddlZe�e�Z	dZ
ejdd��Zdd�Z
dd	�Zd
d�Zdd
�Zdd�ZdS)z
Module for apcupsd
�NZapcupscCstjj�d�S)z<
    Looks to see if apcaccess is present on the system
    �	apcaccess)�salt�utils�path�which�rr�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/apcups.py�_check_apcaccesssr	cCst�rtSdd�t�fS)z7
    Provides apcupsd only if apcaccess is present
    Fz9{} module can only be loaded on when apcupsd is installed)r	�__virtualname__�formatrrrr�__virtual__s��rcCsji}t�}td|�}|d}|dkrd|d<|S|d��D]}|�d�}|d��||d��<q|S)	zm
    Return apcaccess output

    CLI Example:

    .. code-block:: bash

        salt '*' apcups.status
    zcmd.run_all�retcoderz=Something with wrong executing apcaccess, is apcupsd running?�Error�stdout�:�)r	Z__salt__�
splitlines�split�strip)�retr�resr
�linerrr�status&s

rcC�>t�}d|vr|d��}|d��dkrt|d�SddiS)zf
    Return load

    CLI Example:

    .. code-block:: bash

        salt '*' apcups.status_load
    ZLOADPCTr�percentrr�Load not available.�rr�lower�float)�data�loadrrr�status_load?�
r!cCr)zr
    Return battery charge

    CLI Example:

    .. code-block:: bash

        salt '*' apcups.status_charge
    ZBCHARGErrrrrr)rZchargerrr�
status_chargeRr"r#cCs$t�}d|vr|ddkSddiS)z�
    Return true if running on battery power

    CLI Example:

    .. code-block:: bash

        salt '*' apcups.status_battery
    ZTONBATTz	0 SecondsrzBattery status not available.)r)rrrr�status_batteryes
r$)�__doc__�loggingZsalt.utils.decoratorsrZ
decoratorsZsalt.utils.pathr�	getLogger�__name__�logr
Zmemoizer	rrr!r#r$rrrr�<module>s