diff --git a/recipes/build_pkgs/build_pkgs.py b/recipes/build_pkgs/build_pkgs.py index 984203d7d45d33f9e43f177fce565cbd533461ad..dbbf079e20182da358a3d43696d0ac1caf624eff 100644 --- a/recipes/build_pkgs/build_pkgs.py +++ b/recipes/build_pkgs/build_pkgs.py @@ -1,4 +1,4 @@ -import subprocess, os, glob +import subprocess def get_pkg_list(): """ @@ -22,6 +22,7 @@ class Recipe: :param name: (Boilerplate) Name of section that uses this recipe. :param options: (Boilerplate) Options of section that uses this recipe. """ + self.name = name self.options = options self.pkg_list = get_pkg_list() @@ -30,10 +31,10 @@ class Recipe: Install method that runs when recipe has components it needs to install. :return: Paths to files, as strings, created by the recipe. """ - if self.options['name'] == "all": + if self.name == "all": pkgs = self.pkg_list else: - pkgs = self.options['name'].split(',') + pkgs = self.name.split(',') for p in pkgs: if p not in self.pkg_list: diff --git a/tools/transfer_to_builder.py b/tools/transfer_to_builder.py index 085e81807b7f1d8343c5d470edc5405a8e4bf970..ec1c254a989db14f2deb5e1028204de21fbed6d6 100644 --- a/tools/transfer_to_builder.py +++ b/tools/transfer_to_builder.py @@ -15,6 +15,11 @@ def get_build_pkg_names(): return pkg_names def create_ssh_client(server): + """ + Use paramiko to load SSH keys if they exist and set up an SSH connection to a server. + :param server: The server to connect to + :return: Initialized SSH client object. + """ client = paramiko.SSHClient() client.load_system_host_keys() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) @@ -24,13 +29,14 @@ def create_ssh_client(server): def transfer_packages(pkg_names): """ Use shell commands to transfer build archives to builder and update its conda package index. + :param pkg_names: Names of the .tar.bz2 files for the built packages. """ - builder_addr = "builder.aoc.nrao.edu" - builder_path = "/home/builder.aoc.nrao.edu/content/conda/noarch" - ssh = create_ssh_client(builder_addr) - scp = SCPClient(ssh.get_transport()) if len(pkg_names): - scp.put(' '.join(pkg_names), builder_path) + builder_addr = "builder.aoc.nrao.edu" + builder_path = "/home/builder.aoc.nrao.edu/content/conda/noarch" + ssh = create_ssh_client(builder_addr) + with SCPClient(ssh.get_transport()) as scp: + [scp.put(pkg, builder_path) for pkg in pkg_names] cmd_cd = "cd {}".format(builder_path) cmd_index = "conda index .." cmd_chmod = "chmod -f 664 *" @@ -40,7 +46,6 @@ def transfer_packages(pkg_names): cmd_chmod]) else: print("No packages found in pkgs/noarch. Did conda build successfully build the package(s)?") - return if __name__ == "__main__": transfer_packages(get_build_pkg_names()) \ No newline at end of file