M/edZddlZddlmZddlmZddlmZddlm Z eje Z de dee fd Zd e defd Zy) zPlugin utilities.N)List)util)os)STANDARD_BINARY_DIRSpathreturnctjj|}g}|rA|j|tjj |\}}||dk(r |S|rA|S)aRetrieves all possible path prefixes of a path, in descending order of length. For instance: * (Linux) `/a/b/c` returns `['/a/b/c', '/a/b', '/a', '/']` * (Windows) `C:\a\b\c` returns `['C:\a\b\c', 'C:\a\b', 'C:\a', 'C:']` :param str path: the path to break into prefixes :returns: all possible path prefixes of given path in descending order :rtype: `list` of `str` )rrnormpathappendsplit)rprefixprefixes_s 6/usr/lib/python3/dist-packages/certbot/plugins/util.py get_prefixesr sbWW  d #FH GGMM&)  Xb\ !  O  Ocmdctjd}g}tD].}||vs|tj|zz }|j |0t |rGt jd|tjj||tjd<tj|ryt |rdnd}t jd|||y)zAttempt to perform PATH surgery to find cmd Mitigates https://github.com/certbot/certbot/issues/1833 :param str cmd: the command that is being searched for in the PATH :returns: True if the operation succeeded, False otherwise PATHz6Can't find %s, attempting PATH mitigation by adding %sTz expandedz*Failed to find executable %s in%s PATH: %sF) renvironrpathsepr anyloggerdebugjoinr exe_exists)rraddeddexpandeds r path_surgeryr"#s ::f D E ! D= BJJN "D LLO  5z M"**//%0 2! 6 s!%j{bH LL=s4! r)__doc__loggingtypingrcertbotrcertbot.compatrcertbot.compat.miscr getLogger__name__rstrrboolr"rrr.sS4   8 $stCy.cdr