6Minimum working example for PyXMake.
8@note: Install Docker on any machine.
12----------------------------------------------------------------------------------------------
19@author: garb_ma [DLR-FA,STM Braunschweig]
20----------------------------------------------------------------------------------------------
31 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
32 if __package
in os.path.abspath(__file__): sys.path.insert(0,os.path.join(str(os.path.abspath(__file__)).split(__package)[0],__package,
"Plugin"))
36def main(directory=False, feature=False):
38 Main function to execute the script.
39 Installs Docker on the current machine (Windows)
42 if Utility.GetPlatform()
in [
"windows"]:
43 if not directory
or not os.path.exists(directory):
raise FileNotFoundError
44 if not feature
or not feature
in [
"linux",
"windows",
"all"]:
raise IOError
46 subprocess.check_call([Utility.GetExecutable(
"powershell", get_path=
True)[-1],
47 os.path.join(Utility.GetPyXMakePath(),
"Build",
"config",
"stm_docker.ps1"),
48 directory,delimn.join([
"--package",feature])])
52 wget.download(
"https://get.docker.com",
'get-docker.sh')
54 subprocess.check_call([
"sudo",
"sh",
"get-docker.sh",
"&&",
"rm",
"-rf",
"get-docker.sh"])
55 raise NotImplementedError
58if __name__ ==
"__main__":
62 parser = argparse.ArgumentParser(description=
"Set up Docker in WSL2 on the current machine. Requires administrator privileges if Windows containers are desired.")
63 parser.add_argument(
"--directory", metavar=
"directory", nargs=1, help=
"Installation directory (absolute path). Defaults to user workspace.")
64 parser.add_argument(
"--feature", metavar=
"feature", nargs=1, help=
"Name of the package to install. Defaults to all.")
68 args, _ = parser.parse_known_args()
70 try: directory = args.directory[0]
71 except: directory = os.path.expanduser(
"~")
73 try: feature = args.feature[0]
74 except: feature =
"linux"
77 directory = os.path.expanduser(
"~");
81 main(directory, feature)
83 print(
"==================================")
85 print(
"==================================")
main(directory=False, feature=False)