6Install latest STM software on DLR's HPC cluster (CARA).
8@note: Requires GitLab access
12----------------------------------------------------------------------------------------------
19@author: garb_ma [DLR-FA,STM Braunschweig]
20----------------------------------------------------------------------------------------------
30 from urllib
import quote_plus
32 from urllib.parse
import quote_plus
38 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
45__user = os.getenv(
"username")
47def main(user, key="", password="", verbosity=0, **kwargs):
49 Main function to execute the script.
50 Install STM software in the user's workspace on CARA. Installs all packages.
53 access = kwargs.get(
"auth",
""); directory = kwargs.get(
"directory",
"")
54 if not access: access = __delimn.join([user, getpass.getpass()])
55 if access
and __delimn
in access:
56 access = __delimn.join([access.split(__delimn)[0],quote_plus(access.split(__delimn)[-1])]) +
"@"
57 scratch = str(next(tempfile._get_candidate_names()))
59 command =
"git clone --single-branch --recursive --branch pyx_service https://%sgitlab.dlr.de/fa_sw/stmlab/PyXMake.git %s; cd %s && \
60 chmod u+x stm_cara_software.sh && echo '\nrm -rf ../%s' >> stm_cara_software.sh && \
61 sbatch stm_cara_software.sh --internal=true --user='%s' --token='%s' --directory='%s' --package='%s' --refresh='%s'" % (access, scratch,
62 scratch, scratch, access.split(__delimn)[0], access.split(__delimn)[-1].replace(
"@",
""),
63 directory
or posixpath.join(Utility.AsDrive(
"home", posixpath.sep),user,
"software"), kwargs.get(
"feature",
"all"), str(kwargs.get(
"refresh",
"false")))
65 if kwargs.get(
"interactive",
False): command = command.replace(
"sbatch",
"srun")
67 SSHBuild =
Make.SSH(
"cara", [], verbose=verbosity)
69 SSHBuild.OutputPath(
"")
71 SSHBuild.Build(command, run=
"custom")
73 SSHBuild.Settings(user, key, password=password, host=
"cara.dlr.de", use_cache=
False)
74 SSHBuild.create(tty=
True, collect=
False)
76if __name__ ==
"__main__":
80 parser = argparse.ArgumentParser(description=
"Install supported STM software in the user's workspace on CARA.")
81 parser.add_argument(
"user", metavar=
"user", nargs=1, help=
"Current user for SSH connection")
82 parser.add_argument(
"password", metavar=
"password", nargs=1, help=
"Password of current user")
83 parser.add_argument(
"--access", metavar=
"access", nargs=1, help=
"Access token for GitLab in format <Token>:<Value>")
84 parser.add_argument(
"--directory", metavar=
"directory", nargs=1, help=
"Installation directory (absolute path). Defaults to user workspace.")
85 parser.add_argument(
"--feature", metavar=
"feature", nargs=1, help=
"Name of the package to install. Defaults to all.")
86 parser.add_argument(
"--refresh", metavar=
"refresh", nargs=1, help=
"Reinstall the given package if already present. Defaults to False.")
87 parser.add_argument(
"--interactive", metavar=
"interactive", type=Utility.GetBoolean, const=
True, default=
False, nargs=
'?', help=
"Select whether the installation runs interactively.")
91 args, _ = parser.parse_known_args()
97 user = args.user[0]; key =
"";
98 password = args.password[0]
100 try: access = args.access[0]
101 except: access = __delimn.join([user,password])
103 try: directory = args.directory[0]
104 except: directory = posixpath.join(Utility.AsDrive(
"home", posixpath.sep),user,
"software")
106 try: feature = args.feature[0]
107 except: feature =
"all"
109 try: refresh = args.refresh[0]
110 except: refresh =
False
112 try: interactive = args.interactive[0]
113 except: interactive =
False
116 user = __user; password =
""; access =
""; directory=
""; feature=
"all"; refresh =
False; interactive=
False
117 key = os.path.join(Utility.AsDrive(
"C"),
"Users",user,
"Keys",
"Putty",
"id_rsa")
120 main(user, key, password, auth=access, directory=directory, feature=feature, interactive=interactive, refresh=refresh)
122 print(
"==================================")
124 print(
"==================================")
Base class for all build events requiring a SSH connection.
Module containing all relevant modules and scripts associated with the building process.
main(user, key="", password="", verbosity=0, **kwargs)