Returns a string of paths separated by os.pathsep. Users might not have all of the programs sshuttle needs in their PATH variable (i.e., some programs might be in /sbin). Use PATH and a hardcoded set of paths to search through. This function is used by our which() and get_env() func
()
| 198 | |
| 199 | |
| 200 | def get_path(): |
| 201 | """Returns a string of paths separated by os.pathsep. |
| 202 | |
| 203 | Users might not have all of the programs sshuttle needs in their |
| 204 | PATH variable (i.e., some programs might be in /sbin). Use PATH |
| 205 | and a hardcoded set of paths to search through. This function is |
| 206 | used by our which() and get_env() functions. If which() and the |
| 207 | subprocess environments differ, programs that which() finds might |
| 208 | not be found at run time (or vice versa). |
| 209 | """ |
| 210 | path = [] |
| 211 | if "PATH" in os.environ: |
| 212 | path += os.environ["PATH"].split(os.pathsep) |
| 213 | # Python default paths. |
| 214 | path += os.defpath.split(os.pathsep) |
| 215 | # /sbin, etc are not in os.defpath and may not be in PATH either. |
| 216 | # /bin/ and /usr/bin below are probably redundant. |
| 217 | path += ['/bin', '/usr/bin', '/sbin', '/usr/sbin'] |
| 218 | |
| 219 | # Remove duplicates. Not strictly necessary. |
| 220 | path_dedup = [] |
| 221 | for i in path: |
| 222 | if i not in path_dedup: |
| 223 | path_dedup.append(i) |
| 224 | |
| 225 | return os.pathsep.join(path_dedup) |
| 226 | |
| 227 | |
| 228 | if sys.version_info >= (3, 3): |