M/e$ xdZddlmZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z  ddlmZdd lmZdd lmZdd lmZd Zej2eZergdngZd$dZd$dZdedee de fdZ!ddddZ"ddddZ#de de fdZ$de de fdZ% d%d e d!e d"ee&de e'e e ffd#Z(y#e$rd ZYlwxYw)&zk This compat module handles various platform specific calls that do not fall into one particular category. )absolute_importN)Optional)Tuple)errors)os)error)shell) GetStdHandle)STD_OUTPUT_HANDLEFT)z /usr/sbinz/usr/local/binz/usr/local/sbinreturncjts-tjdk(rtjdyy)z On Windows, raise if current shell does not have the administrative rights. Do nothing on Linux. :raises .errors.Error: If the current shell does not have administrative rights on Windows. rzAError, certbot must be run on a shell with administrative rights.N) POSIX_MODE shellwin32 IsUserAnAdminrError5/usr/lib/python3/dist-packages/certbot/compat/misc.py+raise_for_non_administrative_windows_rightsr!s. *2249ll^__::rctryd} tt}|r#|j|j |zyy#t $rt jddYywxYw)zR On Windows, ensure that Console Virtual Terminal Sequences are enabled. NzFailed to set console modeT)exc_info)rr r SetConsoleModeGetConsoleMode pywinerrorloggerdebug)"ENABLE_VIRTUAL_TERMINAL_PROCESSINGhs rprepare_virtual_consoler ,sj *0&B * +  Q--/2TT U B 1D ABs3A A#"A#timeoutpromptc> tjtjggg|\}}}|s0tjdj |r |d|dj S#t$r!tjj cYSwxYw)a( Read user input to return the first line entered, or raise after specified timeout. :param float timeout: The timeout in seconds given to the user. :param str prompt: The prompt message to display to the user. :returns: The first line entered by the user. :rtype: str z,Timed out waiting for answer to prompt '{0}'r)selectsysstdinrrformatreadlineOSError)r!r"rlist_s rreadline_with_timeoutr-@s$mmSYYKRA q!,,>EEPVf_a a\^_a aQx  "" $ yy!!## $sA/A22'BBz C:\CertbotzC:\Certbot\libzC:\Certbot\log)configworklogsz/etc/letsencryptz/var/lib/letsencryptz/var/log/letsencrypt folder_typecLtjdk7r t|St|S)z Return the relevant default folder for the current OS :param str folder_type: The type of folder to retrieve (config, work or logs) :returns: The relevant default folder. :rtype: str nt)rnameLINUX_DEFAULT_FOLDERSWINDOWS_DEFAULT_FOLDERS)r1s rget_default_folderr7is% ww$$[11 "; //rpathctjdk7r|Stjj|\}}||j ddzS)z Replace unsupported characters in path for current OS by underscores. :param str path: the path to normalize :return: the normalized path :rtype: str r3:r,)rr4r8 splitdrivereplace)r8drivetails r.underscores_for_unsupported_characters_in_pathr?zsD ww$ ''$$T*KE4 4<<S) ))rcmd_name shell_cmdenvc ttjd||tr9tj|dtj tj dd|}n~~itJOO%/__$)s4!*i8~~d:??:??15UM {{DKKC ??C $$r)r N)N))__doc__ __future__rloggingr%rIr&typingrrcertbotrcertbot.compatr pywintypesrrwin32com.shellr r win32consoler r r ImportError getLogger__name__rSTANDARD_BINARY_DIRSrr floatstrr-r6r5r7r?dictintrQrrrrcs%'  .2).J   8 $NXI]_`B($5$(3-$C$<   ! " "0C0C0" * * *"26%S%S% (%:?S# :N%gJsB//B98B9