Skip to content
Snippets Groups Projects
Commit 5a818535 authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Added some error checking and comments.

parent 70f1949c
No related branches found
No related tags found
No related merge requests found
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:
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment