_c @ sg d Z d d l Z d d l m Z d d l m Z d d l m Z e j e Z
d Z d Z d S( s Plugin utilities.iN( t util( t os( t STANDARD_BINARY_DIRSc C sb t j j | } g } xC | r] | j | t j j | \ } } | | d k r Pq q W| S( s Retrieves 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`
i( R t patht normpatht appendt split( R t prefixt prefixest _( ( s8 /usr/lib/python2.7/site-packages/certbot/plugins/util.pyt get_prefixes s
c C s t j d } g } x; t D]3 } | | k r | t j | 7} | j | q q Wt | r t j d | t j j | | t j d <n t j
| r t St | r d n d } t j d | | | t S( s Attempt 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
t PATHs6 Can't find %s, attempting PATH mitigation by adding %ss expandedt s* Failed to find executable %s in%s PATH: %s(
R t environR t pathsepR t anyt loggert debugt joinR t
exe_existst Truet False( t cmdR t addedt dt expanded( ( s8 /usr/lib/python2.7/site-packages/certbot/plugins/util.pyt path_surgery s
(
t __doc__t loggingt certbotR t certbot.compatR t certbot.compat.miscR t getLoggert __name__R R
R ( ( ( s8 /usr/lib/python2.7/site-packages/certbot/plugins/util.pyt <module> s