eaiovnaovbqoebvqoeavibavo B  fj @sdZddlZddlZddlZddlZddlZdddgZGdddeZddd Z dd d Z dd d Z dddZ ddZ yddlZejejfWnBeefk ry ddlZWnek re ZYnXe ZYnXe ZdS)aUtilities to get a password and/or the current user name. getpass(prompt[, stream]) - Prompt for a password, with echo turned off. getuser() - Get the user name from the environment or password database. GetPassWarning - This UserWarning is issued when getpass() cannot prevent echoing of the password contents while reading. On Windows, the msvcrt module will be used. NgetpassgetuserGetPassWarningc@s eZdZdS)rN)__name__ __module__ __qualname__rr,/opt/alt/python37/lib64/python3.7/getpass.pyrs Password: c Csd}t}yJtdtjtjB}t|d}||t |}|||sX|}Wnpt k r}zR| yt j }Wn&ttfk rd}t||}YnXt j }|st j}Wdd}~XYnX|dk ryt|}|dd} | dtjM<tj} ttdr| tjO} z t|| | t|||d}Wdt|| ||XWn@tjk r|dk rz||k r| t||}YnX|d|SQRXdS)aPrompt for a password, with echo turned off. Args: prompt: Written on stream to ask for the input. Default: 'Password: ' stream: A writable file object to display the prompt. Defaults to the tty. If no tty is available defaults to sys.stderr. Returns: The seKr3t input. Raises: EOFError: If our input tty or stdin was closed. GetPassWarning: When we were unable to turn echo off on the input. Always restores terminal settings before returning. Nz/dev/ttyzw+TCSASOFT)input ) contextlib ExitStackosopenO_RDWRO_NOCTTYioFileIO enter_context TextIOWrapperOSErrorclosesysstdinfilenoAttributeError ValueErrorfallback_getpassstderrtermios tcgetattrZECHOZ TCSAFLUSHhasattrr tcsetattr _raw_inputflusherrorwrite) promptstreamZpasswdstackfdZttyr eoldnewZtcsetattr_flagsrrr unix_getpasssR             r1cCstjtjk rt||Sx|D]}t|qWd}xHt}|dksL|dkrNP|dkrZt|dkrp|dd}q4||}q4Wtdtd|S)z9Prompt for password with echo off, using Windows getch(). rN)rr __stdin__r msvcrtZputwchZgetwchKeyboardInterrupt)r*r+cZpwrrr win_getpassas"      r;cCs0tjdtdd|stj}td|dt||S)Nz%Can not control echo on the terminal.) stacklevelz&Warning: Password input may be echoed.)file)warningswarnrrr!printr&)r*r+rrr r xs  r r2cCs|s tj}|stj}t|}|rpy||Wn8tk rf||jd}||j}||YnX| | }|st |ddkr|dd}|S)Nreplacer6r) rr!rstrr)UnicodeEncodeErrorencodeencodingdecoder'readlineEOFError)r*r+r linerrr r&s&   r&cCs<x dD]}tj|}|r|SqWddl}|tdS)zGet the username from the environment or password database. First try various environment variables, then the password database. This works on Windows as long as USERNAME is set. )ZLOGNAMEZUSERZLNAMEZUSERNAMErN)renvirongetpwdgetpwuidgetuid)nameuserrMrrr rs   )r N)r N)r N)r2NN)__doc__rrrrr?__all__ UserWarningrr1r;r r&rr"r#r% ImportErrorrr8rrrrr  s,  D