| Current Path : /lib/python3/dist-packages/cloudinit/sources/helpers/__pycache__/ |
| Current File : //lib/python3/dist-packages/cloudinit/sources/helpers/__pycache__/hetzner.cpython-38.pyc |
U
�Ad1 � @ sH d dl Z d dlZd dlmZmZ ddd�Zd
dd�Zeed �d
d�ZdS )� N)�
url_helper�util� � c C s6 t j| |||d�}|�� s&td| ��t�|j�� �S )N��timeout�sec_between�retrieszunable to read metadata at %s)r �readurl�ok�RuntimeErrorr Z load_yaml�contents�decode�Zurlr r r Zresponse� r �C/usr/lib/python3/dist-packages/cloudinit/sources/helpers/hetzner.py�
read_metadata s �r c C s, t j| |||d�}|�� s&td| ��|jS )Nr zunable to read userdata at %s)r r
r r r
r r r r �
read_userdata s �r )�data�returnc C sJ t | t�stdt| � ��ztj| dd�W S tjk
rD | Y S X dS )z�base64 decode data
If data is base64 encoded bytes, return b64decode(data).
If not, return data unmodified.
@param data: data as bytes. TypeError is raised if not bytes.
zdata is '%s', expected bytesT)ZvalidateN)�
isinstance�bytes� TypeError�type�base64Z b64decode�binascii�Error)r r r r �maybe_b64decode s
r )r r r )r r r ) r r Z cloudinitr r r r r r r r r r �<module> s