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