Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/system/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/system/dconf.pyo

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZdZ
yddlZeZWn#ek
r�ej�Z
eZnXddlmZmZd
efd��YZdefd��YZd�Zedkr
e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�	
module: dconf
author:
    - "Branko Majic (@azaghal)"
short_description: Modify and read dconf database
description:
  - This module allows modifications and reading of dconf database. The module
    is implemented as a wrapper around dconf tool. Please see the dconf(1) man
    page for more details.
  - Since C(dconf) requires a running D-Bus session to change values, the module
    will try to detect an existing session and reuse it, or run the tool via
    C(dbus-run-session).
notes:
  - This module depends on C(psutil) Python library (version 4.0.0 and upwards),
    C(dconf), C(dbus-send), and C(dbus-run-session) binaries. Depending on
    distribution you are using, you may need to install additional packages to
    have these available.
  - Detection of existing, running D-Bus session, required to change settings
    via C(dconf), is not 100% reliable due to implementation details of D-Bus
    daemon itself. This might lead to running applications not picking-up
    changes on the fly if options are changed via Ansible and
    C(dbus-run-session).
  - Keep in mind that the C(dconf) CLI tool, which this module wraps around,
    utilises an unusual syntax for the values (GVariant). For example, if you
    wanted to provide a string value, the correct syntax would be
    C(value="'myvalue'") - with single quotes as part of the Ansible parameter
    value.
  - When using loops in combination with a value like
    :code:`"[('xkb', 'us'), ('xkb', 'se')]"`, you need to be aware of possible
    type conversions. Applying a filter :code:`"{{ item.value | string }}"`
    to the parameter variable can avoid potential conversion problems.
  - The easiest way to figure out exact syntax/value you need to provide for a
    key is by making the configuration change in application affected by the
    key, and then having a look at value set via commands C(dconf dump
    /path/to/dir/) or C(dconf read /path/to/key).
version_added: "2.4"
options:
  key:
    required: true
    description:
      - A dconf key to modify or read from the dconf database.
  value:
    required: false
    description:
      - Value to set for the specified dconf key. Value should be specified in
        GVariant format. Due to complexity of this format, it is best to have a
        look at existing values in the dconf database. Required for
        C(state=present).
  state:
    required: false
    default: present
    choices:
      - read
      - present
      - absent
    description:
      - The action to take upon the key/value.
s�
value:
    description: value associated with the requested key
    returned: success, state was "read"
    type: str
    sample: "'Default'"
s7
- name: Configure available keyboard layouts in Gnome
  dconf:
    key: "/org/gnome/desktop/input-sources/sources"
    value: "[('xkb', 'us'), ('xkb', 'se')]"
    state: present

- name: Read currently available keyboard layouts in Gnome
  dconf:
    key: "/org/gnome/desktop/input-sources/sources"
    state: read
  register: keyboard_layouts

- name: Reset the available keyboard layouts in Gnome
  dconf:
    key: "/org/gnome/desktop/input-sources/sources"
    state: absent

- name: Configure available keyboard layouts in Cinnamon
  dconf:
    key: "/org/gnome/libgnomekbd/keyboard/layouts"
    value: "['us', 'se']"
    state: present

- name: Read currently available keyboard layouts in Cinnamon
  dconf:
    key: "/org/gnome/libgnomekbd/keyboard/layouts"
    state: read
  register: keyboard_layouts

- name: Reset the available keyboard layouts in Cinnamon
  dconf:
    key: "/org/gnome/libgnomekbd/keyboard/layouts"
    state: absent

- name: Disable desktop effects in Cinnamon
  dconf:
    key: "/org/cinnamon/desktop-effects"
    value: "false"
    state: present
N(t
AnsibleModuletmissing_required_libtDBusWrappercB`s)eZdZd�Zd�Zd�ZRS(ss
    Helper class that can be used for running a command with a working D-Bus
    session.

    If possible, command will be run against an existing D-Bus session,
    otherwise the session will be spawned via dbus-run-session.

    Example usage:

    dbus_wrapper = DBusWrapper(ansible_module)
    dbus_wrapper.run_command(["printenv", "DBUS_SESSION_BUS_ADDRESS"])
    cC`sD||_|j�|_|jdkr@|jjddt�ndS(s�
        Initialises an instance of the class.

        :param module: Ansible module instance used to signal failures and run commands.
        :type module: AnsibleModule
        sdbus-run-sessiontrequiredN(tmodulet_get_existing_dbus_sessiontdbus_session_bus_addresstNonetget_bin_pathtTrue(tselfR((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pyt__init__�s		c	C`s'tj�}|jjd|�x�tj�D]�}tj|�}|j�\}}}y�||kr�d|j�kr�|j�d}|jjd|�dd|dddg}|jj	|�\}}}|d	kr�|jjd
|�|SnWq-tj
k
rq-Xq-W|jjd�dS(
s�
        Detects and returns an existing D-Bus session bus address.

        :returns: string -- D-Bus session bus address. If a running D-Bus session was not detected, returns None.
        s9Trying to detect existing D-Bus user session for user: %dtDBUS_SESSION_BUS_ADDRESSs1Found D-Bus user session candidate at address: %ss	dbus-sends--address=%ss
--type=signalt/scom.example.testis>Verified D-Bus user session candidate as usable at address: %ssDFailed to find running D-Bus user session, will use dbus-run-sessionN(tostgetuidRtdebugtpsutiltpidstProcesstuidstenvirontrun_commandtAccessDeniedR(	Rtuidtpidtprocesstprocess_real_uidt_t"dbus_session_bus_address_candidatetcommandtrc((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pyR
�s$cC`s�|jdkr|jjd�dg|}|jj|�\}}}|jdkr�|dkr�|jjdd|�q�n1i|jd6}|jj|d|�\}}}|||fS(	s�
        Runs the specified command within a functional D-Bus session. Command is
        effectively passed-on to AnsibleModule.run_command() method, with
        modification for using dbus-run-session if necessary.

        :param command: Command to run, including parameters. Each element of the list should be a string.
        :type module: list

        :returns: tuple(result_code, standard_output, standard_error) -- Result code, standard output, and standard error from running the command.
        s4Using dbus-run-session wrapper for running commands.sdbus-run-sessionitmsgsMFailed to run passed-in command, dbus-run-session faced an internal error: %sRtenviron_updateN(RRRRRt	fail_json(RR&R'toutterrtextra_environment((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pyR�s
!(t__name__t
__module__t__doc__RR
R(((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pyR
�s		&tDconfPreferencecB`s/eZed�Zd�Zd�Zd�ZRS(cC`s||_||_dS(sG
        Initialises instance of the class.

        :param module: Ansible module instance used to signal failures and run commands.
        :type module: AnsibleModule

        :param check_mode: Specify whether to only check if a change should be made or if to actually make a change.
        :type check_mode: bool
        N(Rt
check_mode(RRR2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pyR�s	cC`sxdd|g}|jj|�\}}}|dkrP|jjdd|�n|dkred}n|jd�}|S(	s
        Retrieves current value associated with the dconf key.

        If an error occurs, a call will be made to AnsibleModule.fail_json.

        :returns: string -- Value assigned to the provided key. If the value is not set for specified key, returns None.
        tdconftreadiR(s3dconf failed while reading the value with error: %sts
N(RRR*Rtrstrip(RtkeyR&R'R+R,tvalue((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pyR4�s		cC`s�||j|�krtS|jr&tSdd||g}t|j�}|j|�\}}}|dkr�|jjdd|�ntS(s�
        Writes the value for specified key.

        If an error occurs, a call will be made to AnsibleModule.fail_json.

        :param key: dconf key for which the value should be set. Should be a full path.
        :type key: str

        :param value: Value to set for the specified dconf key. Should be specified in GVariant format.
        :type value: str

        :returns: bool -- True if a change was made, False if no change was required.
        R3twriteiR(s1dconf failed while write the value with error: %s(R4tFalseR2RR
RRR*(RR7R8R&tdbus_wrapperR'R+R,((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pyR9s	cC`s�|j|�}|dkrtS|jr,tSdd|g}t|j�}|j|�\}}}|dkr�|jjdd|�ntS(sV
        Returns value for the specified key (removes it from user configuration).

        If an error occurs, a call will be made to AnsibleModule.fail_json.

        :param key: dconf key to reset. Should be a full path.
        :type key: str

        :returns: bool -- True if a change was made, False if no change was required.
        R3tresetiR(s4dconf failed while reseting the value with error: %sN(	R4RR:R2RR
RRR*(RR7t
current_valueR&R;R'R+R,((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pyR<7s
	(R.R/R:RR4R9R<(((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pyR1�s		$cC`s�tdtdtddddddg�dtd	td
d�dtd	tddd
d��d
t�}ts�|jdtd�dt�n|j	ddkr�|j	ddkr�|jdd�nt
||j�}|j	ddkr|j|j	d�}|j
dtd|�n�|j	ddkr^|j|j	d|j	d�}|j
d|�n<|j	ddkr�|j|j	d�}|j
d|�ndS(Nt
argument_spectstatetdefaulttpresenttchoicestabsentR4R7RttypetstrR8tsupports_check_modeR(Rt	exceptions+State "present" requires "value" to be set.tchanged(RtdictRR:Rtpsutil_foundR*R	tPSUTIL_IMP_ERRtparamsR1R2R4t	exit_jsonR9R<(RR3R8RH((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pytmain\s(	& t__main__(t
__future__RRRRDt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtRETURNtEXAMPLESRt	tracebackRRKRRRJtImportErrort
format_excR:tansible.module_utils.basicRR	tobjectR
R1RNR.(((s@/usr/lib/python2.7/site-packages/ansible/modules/system/dconf.pyt<module>s,


;*


ap	!

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]