%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/mac_system.pyo

�
���^c@@s�dZddlmZmZmZyddlmZWn!ek
rYddl	mZnXddl
Z
ddlZddl
mZmZdZd�Zd�Zd	�Zdd
�Zdd�Zdd�Zdd
�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)dd �Z*dS(!u�
System module for sleeping, restarting, and shutting down the system on Mac OS X

.. versionadded:: 2016.3.0

.. warning::
    Using this module will enable ``atrun`` on the system if it is disabled.
i(tabsolute_importtunicode_literalstprint_function(tquoteN(tSaltInvocationErrortCommandExecutionErrorusystemcC@s[tjjj�stdfStj�dkr8tdfSt�sWt�sWtdfSnt	S(u+
    Only for MacOS with atrun enabled
    uNThe mac_system module could not be loaded: module only works on MacOS systems.urootu7The mac_system module is not useful for non-root users.u)atrun could not be enabled on this system(
tsalttutilstplatformt	is_darwintFalsetgetpasstgetusert_atrun_enabledt
_enable_atrunt__virtualname__(((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pyt__virtual__s

		
cC@s+ytdd�SWntk
r&tSXdS(uD
    Check to see if atrun is running and enabled on the system
    uservice.listucom.apple.atrunN(t__salt__RR
(((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pyR
-s
cC@sBd}y td|�td|�Wntk
r:tSXt�S(u+
    Enable and start the atrun daemon
    ucom.apple.atrunuservice.enableu
service.start(RRR
R
(tname((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pyR7s
cC@s<|r!dj|t|��}nttd|dt��S(u�
    Helper function to execute the command

    :param str cmd: the command to run

    :param str at_time: If passed, the cmd will be scheduled.

    Returns: bool
    uecho '{0}' | at {1}ucmd.retcodetpython_shell(tformatt
_cmd_quotetboolRtTrue(tcmdtat_time((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pyt_execute_commandDs
cC@sd}t||�S(u'
    Halt a running system

    :param str at_time: Any valid `at` expression. For example, some valid at
        expressions could be:

        - noon
        - midnight
        - fri
        - 9:00 AM
        - 2:30 PM tomorrow
        - now + 10 minutes

    .. note::
        If you pass a time only, with no 'AM/PM' designation, you have to
        double quote the parameter on the command line. For example: '"14:00"'

    CLI Example:

    .. code-block:: bash

        salt '*' system.halt
        salt '*' system.halt 'now + 10 minutes'
    ushutdown -h now(R(RR((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pythaltSscC@sd}t||�S(ua
    Sleep the system. If a user is active on the system it will likely fail to
    sleep.

    :param str at_time: Any valid `at` expression. For example, some valid at
        expressions could be:

        - noon
        - midnight
        - fri
        - 9:00 AM
        - 2:30 PM tomorrow
        - now + 10 minutes

    .. note::
        If you pass a time only, with no 'AM/PM' designation, you have to
        double quote the parameter on the command line. For example: '"14:00"'

    CLI Example:

    .. code-block:: bash

        salt '*' system.sleep
        salt '*' system.sleep '10:00 PM'
    ushutdown -s now(R(RR((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytsleeppscC@sd}t||�S(u&
    Restart the system

    :param str at_time: Any valid `at` expression. For example, some valid at
        expressions could be:

        - noon
        - midnight
        - fri
        - 9:00 AM
        - 2:30 PM tomorrow
        - now + 10 minutes

    .. note::
        If you pass a time only, with no 'AM/PM' designation, you have to
        double quote the parameter on the command line. For example: '"14:00"'

    CLI Example:

    .. code-block:: bash

        salt '*' system.restart
        salt '*' system.restart '12:00 PM fri'
    ushutdown -r now(R(RR((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytrestart�scC@s
t|�S(u)
    Shutdown the system

    :param str at_time: Any valid `at` expression. For example, some valid at
        expressions could be:

        - noon
        - midnight
        - fri
        - 9:00 AM
        - 2:30 PM tomorrow
        - now + 10 minutes

    .. note::
        If you pass a time only, with no 'AM/PM' designation, you have to
        double quote the parameter on the command line. For example: '"14:00"'

    CLI Example:

    .. code-block:: bash

        salt '*' system.shutdown
        salt '*' system.shutdown 'now + 1 hour'
    (R(R((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytshutdown�scC@s4tdd�}tdtd|��}|dkS(u�
    Displays whether remote login (SSH) is on or off.

    :return: True if remote login is on, False if off
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.get_remote_login
    umac_utils.execute_return_resultusystemsetup -getremoteloginumac_utils.validate_enabledumac_utils.parse_returnuon(t	__utils__(trettenabled((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytget_remote_login�s

	cC@sDtd|�}dj|�}td|�td|tdt�S(u�
    Set the remote login (SSH) to either on or off.

    :param bool enable: True to enable, False to disable. "On" and "Off" are
        also acceptable values. Additionally you can pass 1 and 0 to represent
        True and False respectively

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.set_remote_login True
    umac_utils.validate_enabledu"systemsetup -f -setremotelogin {0}u mac_utils.execute_return_successumac_utils.confirm_updatedt
normalize_ret(RRR"R(tenabletstateR((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytset_remote_login�s
cC@s4tdd�}tdtd|��}|dkS(u�
    Displays whether remote apple events are on or off.

    :return: True if remote apple events are on, False if off
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.get_remote_events
    umac_utils.execute_return_resultu!systemsetup -getremoteappleeventsumac_utils.validate_enabledumac_utils.parse_returnuon(R(R R!((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytget_remote_events�s

	cC@sDtd|�}dj|�}td|�td|tdt�S(u�
    Set whether the server responds to events sent by other computers (such as
    AppleScripts)

    :param bool enable: True to enable, False to disable. "On" and "Off" are
        also acceptable values. Additionally you can pass 1 and 0 to represent
        True and False respectively

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.set_remote_events On
    umac_utils.validate_enabledu%systemsetup -setremoteappleevents {0}u mac_utils.execute_return_successumac_utils.confirm_updatedR#(RRR'R(R$R%R((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytset_remote_eventsscC@stdd�}td|�S(u�
    Gets the computer name

    :return: The computer name
    :rtype: str

    CLI Example:

    .. code-block:: bash

        salt '*' system.get_computer_name
    umac_utils.execute_return_resultuscutil --get ComputerNameumac_utils.parse_return(R(R ((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytget_computer_name,s
	cC@s.dj|�}td|�td|t�S(u�
    Set the computer name

    :param str name: The new computer name

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.set_computer_name "Mike's Mac"
    uscutil --set ComputerName "{0}"u mac_utils.execute_return_successumac_utils.confirm_updated(RRR)(RR((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytset_computer_name?s
cC@stdd�}td|�S(u�
    Gets the local subnet name

    :return: The local subnet name
    :rtype: str

    CLI Example:

    .. code-block:: bash

        salt '*' system.get_subnet_name
    umac_utils.execute_return_resultusystemsetup -getlocalsubnetnameumac_utils.parse_return(R(R ((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytget_subnet_nameWs
	cC@s.dj|�}td|�td|t�S(u�
    Set the local subnet name

    :param str name: The new local subnet name

    .. note::
       Spaces are changed to dashes. Other special characters are removed.

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        The following will be set as 'Mikes-Mac'
        salt '*' system.set_subnet_name "Mike's Mac"
    u%systemsetup -setlocalsubnetname "{0}"u mac_utils.execute_return_successumac_utils.confirm_updated(RRR+(RR((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytset_subnet_namejs
cC@stdd�}td|�S(u�
    Displays the current startup disk

    :return: The current startup disk
    :rtype: str

    CLI Example:

    .. code-block:: bash

        salt '*' system.get_startup_disk
    umac_utils.execute_return_resultusystemsetup -getstartupdiskumac_utils.parse_return(R(R ((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytget_startup_disk�s
	cC@stdd�}|j�S(u�
    List all valid startup disks on the system.

    :return: A list of valid startup disks
    :rtype: list

    CLI Example:

    .. code-block:: bash

        salt '*' system.list_startup_disks
    umac_utils.execute_return_resultusystemsetup -liststartupdisks(Rt
splitlines(R ((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytlist_startup_disks�s
	cC@s[|t�kr-dj|�}t|��ndj|�}td|�td|t�S(us
    Set the current startup disk to the indicated path. Use
    ``system.list_startup_disks`` to find valid startup disks on the system.

    :param str path: The valid startup disk path

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.set_startup_disk /System/Library/CoreServices
    unInvalid value passed for path.
Must be a valid startup disk as found in system.list_startup_disks.
Passed: {0}usystemsetup -setstartupdisk {0}umac_utils.execute_return_resultumac_utils.confirm_updated(R/RRRR-(tpathtmsgR((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytset_startup_disk�s	cC@stdd�}td|�S(uC
    Get the number of seconds after which the computer will start up after a
    power failure.

    :return: A string value representing the number of seconds the system will
        delay restart after power loss
    :rtype: str

    CLI Example:

    .. code-block:: bash

        salt '*' system.get_restart_delay
    umac_utils.execute_return_resultu/systemsetup -getwaitforstartupafterpowerfailureumac_utils.parse_return(R(R ((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytget_restart_delay�s	cC@s\|ddkr.dj|�}t|��ndj|�}td|�td|t�S(u�
    Set the number of seconds after which the computer will start up after a
    power failure.

    .. warning::

        This command fails with the following error:

        ``Error, IOServiceOpen returned 0x10000003``

        The setting is not updated. This is an apple bug. It seems like it may
        only work on certain versions of Mac Server X. This article explains the
        issue in more detail, though it is quite old.

        http://lists.apple.com/archives/macos-x-server/2006/Jul/msg00967.html

    :param int seconds: The number of seconds. Must be a multiple of 30

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.set_restart_delay 180
    iiuGInvalid value passed for seconds.
Must be a multiple of 30.
Passed: {0}u3systemsetup -setwaitforstartupafterpowerfailure {0}u mac_utils.execute_return_successumac_utils.confirm_updated(RRRR3(tsecondsR1R((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytset_restart_delay�s	cC@s4tdd�}tdtd|��}|dkS(u!
    Get whether or not the keyboard should be disabled when the X Serve enclosure
    lock is engaged.

    :return: True if disable keyboard on lock is on, False if off
    :rtype: bool

    CLI Example:

    ..code-block:: bash

        salt '*' system.get_disable_keyboard_on_lock
    umac_utils.execute_return_resultu9systemsetup -getdisablekeyboardwhenenclosurelockisengagedumac_utils.validate_enabledumac_utils.parse_returnuon(R(R R!((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytget_disable_keyboard_on_locks
	cC@sDtd|�}dj|�}td|�td|tdt�S(u�
    Get whether or not the keyboard should be disabled when the X Serve
    enclosure lock is engaged.

    :param bool enable: True to enable, False to disable. "On" and "Off" are
        also acceptable values. Additionally you can pass 1 and 0 to represent
        True and False respectively

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.set_disable_keyboard_on_lock False
    umac_utils.validate_enabledu=systemsetup -setdisablekeyboardwhenenclosurelockisengaged {0}u mac_utils.execute_return_successumac_utils.confirm_updatedR#(RRR6R(R$R%R((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pytset_disable_keyboard_on_lock#s	cC@sTtdd�}td|�}d|kr0dSd|kr@dSd|krPdSdS(u�
    Get the kernel architecture setting from ``com.apple.Boot.plist``

    :return: A string value representing the boot architecture setting
    :rtype: str

    CLI Example:

    .. code-block:: bash

        salt '*' system.get_boot_arch
    umac_utils.execute_return_resultu-systemsetup -getkernelbootarchitecturesettingumac_utils.parse_returnudefaultui386ux86_64uunknown(R(R tarch((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pyt
get_boot_archBs
	udefaultcC@sX|dkr*dj|�}t|��ndj|�}td|�td|t�S(	u�
    Set the kernel to boot in 32 or 64 bit mode on next boot.

    .. note::
        When this function fails with the error ``changes to kernel
        architecture failed to save!``, then the boot arch is not updated.
        This is either an Apple bug, not available on the test system, or a
        result of system files being locked down in macOS (SIP Protection).

    :param str arch: A string representing the desired architecture. If no
        value is passed, default is assumed. Valid values include:

        - i386
        - x86_64
        - default

    :return: True if successful, False if not
    :rtype: bool

    CLI Example:

    .. code-block:: bash

        salt '*' system.set_boot_arch i386
    ui386ux86_64udefaultuLInvalid value passed for arch.
Must be i386, x86_64, or default.
Passed: {0}u*systemsetup -setkernelbootarchitecture {0}u mac_utils.execute_return_successumac_utils.confirm_updated(ui386ux86_64udefault(RRRR9(R8R1R((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pyt
set_boot_arch^s	(+t__doc__t
__future__RRRtshlexRRtImportErrortpipesRtsalt.utils.platformRtsalt.exceptionsRRRRR
RtNoneRRRRRR"R&R'R(R)R*R+R,R-R/R2R3R5R6R7R9R:(((s;/usr/lib/python2.7/site-packages/salt/modules/mac_system.pyt<module>	sD
		
	
											 		+			

Zerion Mini Shell 1.0