|
|
|
@ -8,12 +8,14 @@ import shutil
|
|
|
|
|
import os
|
|
|
|
|
from functools import cached_property
|
|
|
|
|
|
|
|
|
|
from . import host
|
|
|
|
|
from .host import host
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Target:
|
|
|
|
|
"""
|
|
|
|
|
base class of all target platforms
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def target_path(self, relpath):
|
|
|
|
|
"""
|
|
|
|
|
computes the path of a file in the home directory
|
|
|
|
@ -79,32 +81,36 @@ class Target:
|
|
|
|
|
target_path.symlink_to(source_path)
|
|
|
|
|
print("")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Linux(Target):
|
|
|
|
|
"""
|
|
|
|
|
defines a local Linux target: the local machine when the script is run on
|
|
|
|
|
Linux
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Windows(Target):
|
|
|
|
|
"""
|
|
|
|
|
defines a local Windows target: the local machine when the script is run on
|
|
|
|
|
Windows
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WSLHost(Target):
|
|
|
|
|
"""
|
|
|
|
|
defines the Windows machine on which the WSL instance is hosted
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@cached_property
|
|
|
|
|
def target_root(self):
|
|
|
|
|
if not host.is_wsl:
|
|
|
|
|
raise Exception("cannot get windows home dir from anything other than wsl")
|
|
|
|
|
res = subprocess.run(['wslvar', 'USERPROFILE'], check=False,
|
|
|
|
|
capture_output=True)
|
|
|
|
|
winpath = res.stdout.decode('utf-8').strip()
|
|
|
|
|
res = subprocess.run(['wslpath', winpath], check=False,
|
|
|
|
|
capture_output=True)
|
|
|
|
|
return pathlib.Path(res.stdout.decode('utf-8').strip())
|
|
|
|
|
res = subprocess.run(
|
|
|
|
|
["wslvar", "USERPROFILE"], check=False, capture_output=True
|
|
|
|
|
)
|
|
|
|
|
winpath = res.stdout.decode("utf-8").strip()
|
|
|
|
|
res = subprocess.run(["wslpath", winpath], check=False, capture_output=True)
|
|
|
|
|
return pathlib.Path(res.stdout.decode("utf-8").strip())
|
|
|
|
|
|
|
|
|
|
def map_file(self, source_path, target_path):
|
|
|
|
|
"""
|
|
|
|
|