U
    •uÄc™  ã                   @   sx   d dl Z d dlZd dlmZ d dlmZ d dlmZ dZdee	e	e
ed	œd
d„Zedkrtd dlmZ dd„ Zeeƒ dS )é    N)ÚDeferred)ÚIReactorProcess)ÚgetProcessOutput)Úget_input_from_dialogú
Unlock keyú%Please enter passphrase to unlock keyT)ÚreactorÚtitleÚtextÚ	hide_textÚreturnc                 C   sZ   t  d¡}|stdƒ‚dd|d|g}|r2| d¡ t||tj| d�}dd	„ }| |¡ |S )
aí  
    Show a Gnome/GTK desktop dialog asking for a passphrase.

    This is using zenity, the GNOME port of dialog which allows you to display dialog boxes
    from the commandline and shell scripts. To install (on Linux):

    .. code:: console

        sudo apt update
        sudo install zenity

    See also:

    - https://gitlab.gnome.org/GNOME/zenity
    - https://wiki.ubuntuusers.de/Zenity/
    - https://bash.cyberciti.biz/guide/Zenity:_Shell_Scripting_with_Gnome

    :param reactor: Twisted reactor to use.
    :param title: Dialog window title to show.
    :param text: Dialog text to show above text entry field.
    :param hide_text: Hide entry field text.

    :return: A deferred that resolves with the string the user entered.
    ZzenityzRget_input_from_dialog(): could not find zenity (install with "apt install zenity")z--entryz--titlez--textz--hide-text)ÚargsÚenvr   c                 S   s   |   d¡ ¡ }|S )NÚutf8)ÚdecodeÚstrip)ÚoutputÚ
passphrase© r   úS/var/www/html/pearl/school/venv/lib/python3.8/site-packages/autobahn/xbr/_dialog.pyÚ_consumeH   s    z'get_input_from_dialog.<locals>._consume)ÚshutilÚwhichÚRuntimeErrorÚappendr   ÚosÚenvironZaddCallback)r   r	   r
   r   Zexer   Údr   r   r   r   r   %   s    


r   Ú__main__)Úreactc                 Ã   s,   t | ƒI d H }tt|ƒt|ƒd |¡ƒ d S )Nz"{}")r   ÚprintÚtypeÚlenÚformat)r   r   r   r   r   ÚmainS   s    r$   )r   r   T)r   r   Ztwisted.internet.deferr   Ztwisted.internet.interfacesr   Ztwisted.internet.utilsr   Ú__all__ÚstrÚboolr   Ú__name__Ztwisted.internet.taskr   r$   r   r   r   r   Ú<module>   s"      þ þ+