|
24 | 24 | logger = logging.getLogger("murfey.util") |
25 | 25 |
|
26 | 26 |
|
27 | | -def posix_path(path: Path) -> str: |
28 | | - """ |
29 | | - Converts a Windows-style path into a Posix one. Used primarily when running |
30 | | - subproceses in bash terminals, which can only accept Posix paths. |
31 | | - """ |
32 | | - path_parts = list(path.parts) |
33 | | - # Check if it's a Windows-style path |
34 | | - if path_parts[0].endswith((":/", ":\\")): |
35 | | - path_parts[0] = "/" + path_parts[0].strip(":/\\").lower() |
36 | | - posix_path = "/".join(path_parts) |
37 | | - return posix_path |
38 | | - return str(path) |
39 | | - |
40 | | - |
41 | 27 | def read_config() -> configparser.ConfigParser: |
42 | 28 | config = configparser.ConfigParser() |
43 | 29 | try: |
@@ -81,6 +67,22 @@ def secure_path(in_path: Path) -> Path: |
81 | 67 | return Path("/".join(secured_parts)) |
82 | 68 |
|
83 | 69 |
|
| 70 | +def posix_path(path: Path) -> str: |
| 71 | + """ |
| 72 | + Converts a Windows-style path into a Posix one. Used primarily when running |
| 73 | + subproceses in bash terminals on Windows devices, which can only accept |
| 74 | + Posix paths. |
| 75 | + """ |
| 76 | + path_parts = list(path.parts) |
| 77 | + # Check if it's a Windows-style path and converts it to a Posix one |
| 78 | + # e.g.: C:\Users\user -> /c/Users/user |
| 79 | + if path_parts[0].endswith((":/", ":\\")): |
| 80 | + path_parts[0] = "/" + path_parts[0].strip(":/\\").lower() |
| 81 | + posix_path = "/".join(path_parts) |
| 82 | + return posix_path |
| 83 | + return str(path) |
| 84 | + |
| 85 | + |
84 | 86 | @lru_cache(maxsize=1) |
85 | 87 | def get_machine_config(url: str, instrument_name: str = "", demo: bool = False) -> dict: |
86 | 88 | _instrument_name: str | None = instrument_name or os.getenv("BEAMLINE") |
|
0 commit comments