o
    th                     @   s@   d dl Z d dlmZ d dlmZ e eZG dd dejZdS )    Nsubp)debianc                       sF   e Zd ZdedededefddZdd	d
Zdef fddZ  ZS )Distrolayoutmodelvariantoptionsc                 C   s   t  dd|g dS )zKCurrently Raspberry Pi OS sys-mods only supports
        setting the layoutz+/usr/lib/raspberrypi-sys-mods/imager_custom
set_keymapNr   )selfr   r   r   r	    r   C/usr/lib/python3/dist-packages/cloudinit/distros/raspberry_pi_os.pyr
      s   zDistro.set_keymapNLANGc              
   C   sp   zt  ddd| g W d S  t jy7   |ds/td| t  ddd| dg Y d S td Y d S w )Nz/usr/bin/raspi-confignonintdo_change_localez.UTF-8zTrying to set locale %s.UTF-8zFailed to set locale %s)r   ProcessExecutionErrorendswithLOGinfoerror)r   localeout_fnkeynamer   r   r   apply_locale   s(   


	zDistro.apply_localereturnc              
      sn   t  j|fi |}|s|S ztjg dd|id W dS  tjy6 } ztd| W Y d}~dS d}~ww )z
        Add a user to the system using standard GNU tools

        This should be overridden on distros where useradd is not desirable or
        not available.

        Returns False if user already exists, otherwise True.
        )z/usr/bin/rename-userz-fz-s	SUDO_USER)
update_envzFailed to setup user: %sNFT)superadd_userr   r   r   r   )r   namekwargsresulte	__class__r   r   r   4   s   	zDistro.add_user)Nr   )	__name__
__module____qualname__strr
   r   boolr   __classcell__r   r   r#   r   r      s    
r   )	logging	cloudinitr   cloudinit.distrosr   	getLoggerr%   r   r   r   r   r   r   <module>   s
   
