Current Dir: /snap/core22/2955/usr/lib/python3/dist-packages/cloudinit/config/__pycache__/

[FILE] cc_ansible.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apk_configure.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apt_configure.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apt_pipelining.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_bootcmd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_byobu.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ca_certs.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_chef.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_disable_ec2_metadata.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_disk_setup.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_fan.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_final_message.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_growpart.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_grub_dpkg.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_install_hotplug.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_keyboard.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_keys_to_console.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_landscape.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_locale.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_lxd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_mcollective.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_mounts.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ntp.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_package_update_upgrade_install.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_phone_home.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_power_state_change.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_puppet.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_raspberry_pi.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_reset_rmc.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_resizefs.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_resolv_conf.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_rh_subscription.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_rsyslog.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_runcmd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_salt_minion.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_boot.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_instance.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_once.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_user.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_vendor.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_seed_random.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_set_hostname.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_set_passwords.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_snap.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_spacewalk.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh_authkey_fingerprints.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh_import_id.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_timezone.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_autoinstall.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_drivers.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_pro.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_update_etc_hosts.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_update_hostname.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_users_groups.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_wireguard.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_write_files.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_write_files_deferred.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_yum_add_repo.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_zypper_add_repo.cpython-310.pyc [ edit | delete | rename ]
[FILE] modules.cpython-310.pyc [ edit | delete | rename ]
[FILE] schema.cpython-310.pyc [ edit | delete | rename ]
[FILE] __init__.cpython-310.pyc [ edit | delete | rename ]

Viewing: /snap/core22/2955/usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_raspberry_pi.cpython-310.pyc

o

��i�!�
@sUddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
e�e�ZdZd	Zd
Zddd
d�ZdZdZdZdZdZddge
egd�Zeed<dedefdd�Zdefdd�Zdeeefdefdd �Z d!e!dedefd"d#�Z"d$e!de	d%ed&e#ddf
d'd(�Z$dS))�N)�Union)�subp)�Cloud)�Config)�
MetaSchema)�PER_INSTANCE�rpi�
interfaces�enable_usb_gadget�do_spi�do_i2c�
do_onewire)�spi�i2c�onewire�serial�do_serial_cons�do_serial_hwz/usr/bin/rpi-usb-gadgetz(Rebooting to apply config.txt changes...�cc_raspberry_pizraspberry-pi-os)�id�distros�	frequency�activate_by_schema_keys�meta�enable�returnc
Cs�t�d|�tj�t�st�dt�dSztjt|rdnddgddd�Wd	Stjy@}z
t�d
|�WYd}~dSd}~ww)zEnable / Disable Raspberry Pi USB gadget mode when
    the script is present.

    Returns True when a reboot is required.
    zEnable rpi-usb-gadget mode: %sz#rpi-usb-gadget script not found: %sF�on�offz-f�)�capture�timeoutTz&Failed to configure rpi-usb-gadget: %sN)	�LOG�debug�os�path�exists�RPI_USB_GADGET_SCRIPT�errorr�ProcessExecutionError)r�e�r*�B/usr/lib/python3/dist-packages/cloudinit/config/cc_raspberry_pi.py�configure_usb_gadget(s&
����r,cCs,z
t�gd��WdStjyYdSw)N)�/usr/bin/raspi-config�nonint�	is_pifiveTF)rr(r*r*r*r+r/Ks�r/�cfgc
Cs
ddtdtfdd�}d}d}t|t�r||d�}||d�}nt|t�r%|}t�s,|r,d}zt�d	d
tt|r7dnd�g�WntjyW}z
t�	d
|�WYd}~dSd}~wwzt�d	d
t
t|rcdnd�g�WdStjy�}z
t�	d|�WYd}~dSd}~ww)auConfigure the serial (UART) interface on Raspberry Pi.

    Depending on the configuration, this enables or disables
    the serial console and the hardware UART by invoking
    `raspi-config` non-interactively.

    Args:
        cfg: Either a boolean or a dictionary:
            - If a bool, enables or disables the serial
              console and hardware UART together.
            - If a dict, may contain the keys `console`
              and `hardware` with boolean values controlling
              each individually.

    Returns:
        True if the configuration was applied successfully,
        False otherwise.
    F�cfg_dict�namecSs.|�||�}t|t�st�dt||�|S|S)Nz"Invalid value for %s.serial.%s: %s)�get�
isinstance�boolr!�warning�RPI_INTERFACES_KEY)r1r2�default�valr*r*r+�get_bool_fieldgs
�z2configure_serial_interface.<locals>.get_bool_field�console�hardwareTr-r.r�z&Failed to configure serial console: %sNz'Failed to configure serial hardware: %s)F)�dict�strr4r5r/r�RASPI_CONFIG_SERIAL_CONS_FNr(r!r'�RASPI_CONFIG_SERIAL_HW_FN)r0r:�enable_console�	enable_hwr)r*r*r+�configure_serial_interfaceSsJ



��������rD�ifacec
Csz|t��vs
Jd|����zt�ddt|t|rdnd�g�WdStjy<}zt�d||�WYd}~d	Sd}~ww)
a�Enable or disable a supported hardware interface.

    Supported interfaces are defined in `SUPPORTED_INTERFACES` and
    currently include SPI, I2C, and 1-Wire. The function applies
    the change using `raspi-config` in non-interactive mode.

    Args:
        iface: The interface name (e.g. `"spi"` or `"i2c"`).
        enable: True to enable the interface, False to disable it.

    Returns:
        True if the interface configuration succeeded, False otherwise.
    zUnsupported interface: r-r.rr=TzFailed to configure %s: %sNF)�SUPPORTED_INTERFACES�keysrr?r(r!r')rErr)r*r*r+�configure_interface�s"���	��rHr2�cloud�argsc
Cs�t|vrdSt|tt�st�dt|t�dS|ts$t�dt�dSd}|tD]�}|tkrJ|t|}t|t�rB|t|�O}nt	dt����q*|t
kr�t|t|t�set�dt|t|�dS|t|stt�d|�dSt|t|���}|D]L}|t
��vr�|tkr�t�dt
|�q�|t||}|tkr�t|ttf�s�t�dt
||�n|t|�O}q�t|t�r�|t||�O}q�t�dt
||�q�q*t�d|�q*|dur�|jjd	d
td�}	t�|	�dSdS)NzInvalid value for %s: %szEmpty value for %s. Skipping...FzInvalid value for zInvalid key for %s: %szInvalid value for %s.%s: %szUnsupported key: %sT�reboot�now)�mode�delay�message)�RPI_BASE_KEYr4r>r!r6r"�ENABLE_USB_GADGET_KEYr5r,�
ValueErrorr7�listrGrF�SERIAL_INTERFACErDrH�distro�shutdown_command�
REBOOT_MSGr)
r2r0rIrJ�want_reboot�keyr�subkeys�subkey�cmdr*r*r+�handle�s��

���
��"��r])%�loggingr#�typingr�	cloudinitr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar�cloudinit.settingsr�	getLogger�__name__r!rPr7rQrFrTr@rAr&rWr�__annotations__r5r,r/r>rDr?rHrSr]r*r*r*r+�<module>s>

��#N""
Upload File: