-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppUWTools.py
36 lines (28 loc) · 1.46 KB
/
ppUWTools.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
#!/usr/bin/env python
def startServers(ppservers = ('fig.amath.washington.edu:8080', 'lemon.amath.washington.edu:8080'), serverDirectory = '~/DDMCube'):
import os, subprocess, time, socket
localMachine = socket.gethostname()
serverDirectory = os.path.expanduser(serverDirectory)
p = []
for currServerAndPort in ppservers:
currServer, currPort = currServerAndPort.split(':')
if not(currServer == localMachine):
command = 'cd ' + serverDirectory + '; ppserver.py -p ' + str(currPort)
p.append(subprocess.Popen(['ssh ' + currServer + ' \'' + command + ' \''], stdout=subprocess.PIPE, shell=True))
print ' ' + currServer + ': Initialized'
else:
print ' ' + currServer + ': Initialized'
print ' Finalizing cluster...'
time.sleep(5)
return p
def killAllServers(ppservers = ('fig.amath.washington.edu:8080', 'lemon.amath.washington.edu:8080'), serverDirectory = '~/DDMCube'):
import os, subprocess, time
userName = os.getlogin()
p = []
for currServerAndPort in ppservers:
currServer, currPort = currServerAndPort.split(':')
command = 'cd ' + serverDirectory + '; python ppserverKill.py -u ' + userName + ' -p ' + str(currPort)
p.append(subprocess.Popen(['ssh ' + currServer + ' \'' + command + ' \''], stdout=subprocess.PIPE, shell=True))
print ' ' + currServer + ': Shutdown complete'
time.sleep(5)
return p