-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.py
61 lines (49 loc) · 1.77 KB
/
deploy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import pexpect
import paramiko
import os
def runSSHWithCommand(command):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(hostname='hostname', username='user',
password='password')
except Exception as e:
print e;
channel = ssh.get_transport().open_session()
channel.exec_command(command = command)
channel.shutdown_write()
stdout = channel.makefile().read()
stderr = channel.makefile_stderr().read()
exit_code = channel.recv_exit_status()
channel.close()
ssh.close()
print('stdout:\n' + stdout)
print('stderr:' + stderr)
print('exit_code:' + str(exit_code))
def runMakeCheck():
runSSHWithCommand('source ~/.profile && cd ~/gpudb/gpu-no-sql/src && make clean && make check')
def runMakeTopCheck():
runSSHWithCommand('source ~/.profile && cd ~/gpudb/gpu-no-sql/src && make clean && make topcheck')
def cleanOldGPUDB():
print('removing old files in ~/gpudb/gpu-no-sql/')
runSSHWithCommand('rm -rf ~/gpudb/gpu-no-sql/')
try:
cleanOldGPUDB()
cwd = os.path.dirname(os.path.realpath(__file__))
spawnCommand = 'scp -r ' + cwd + ' [email protected]:~/gpudb/'
print spawnCommand
submission = pexpect.spawn(command = spawnCommand, timeout=300)
submission.timeout = 300
submissionResult = submission.expect(["Password:", pexpect.EOF])
if submissionResult is not 0:
print "Connection timeout"
exit(1);
else:
submission.sendline('hf11Ben3ftb7whq')
submission.expect(pexpect.EOF)
print('copy to remote complete, running make check')
runMakeCheck()
print('copy to remote complete, running make topcheck')
runMakeTopCheck()
except Exception as e:
print e;