def makeDirs (path): baseDir = BASE_UPLOAD_TO_DIR dirPaths = [] for dirPath in path.split("/"): actualDirPath = os.path.join(baseDir, dirPath) dirPaths.append(actualDirPath) baseDir = actualDirPath if dirPaths is not None and len(dirPaths) > 1: del dirPaths[len(dirPaths)-1] # Remove the file name client = SSHClient() client.load_system_host_keys() client.connect("bdholmes.com", username="******") for dirPath in dirPaths: stdin, stdout, stderr = client.exec_command("mkdir " + dirPath) error = False for std in [stdout, stderr]: if len(std.readlines()) > 0: error = True for line in std.readlines(): print line if not error: print "Created dir " + dirPath + "..."
def restartDjangoServer (): client = SSHClient() client.load_system_host_keys() client.connect("bdholmes.com", username="******") stdin, stdout, stderr = client.exec_command("touch " + UWSGI_LOCATION) if len(stdout.readlines()) > 0: for line in stdout.readlines(): print line else: print "Django server restarted!"
#!/usr/bin/env python import os import ssh from ssh import SSHClient host="10.107.105.201" user="******" client = SSHClient() client.load_system_host_keys() client.connect(host, username=user) stdin, stdout, stderr = client.exec_command('(cd /home/user1/simulations/decoder_optimised/decoder_node_1; python python_GNUparallel_ngspice.py --num=10 --ssh=/home/user1/simulations/decoder_optimised/decoder_node_1/sshmachines.txt --dir=/home/user1/simulations/decoder_optimised/decoder_node_1/decoder_node_1_line1 --spc=decoder_node_1_line1_sim)') print "stderr: ", stderr.readlines() print "pwd: ", stdout.readlines()