-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcopy_files.py
39 lines (30 loc) · 993 Bytes
/
copy_files.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Copy files from servers
"""
import sys
import os
import time
def child(ip_addr):
if not os.path.exists('outputs/' + ip_addr):
os.makedirs('outputs/' + ip_addr)
cmd = 'scp -r -i ~/.ssh/dist-sgd-sshkey michaelfarrell@%s:~/Distributed-SGD/lua-lua/*.txt ~/Desktop/GoogleDrive/FinalProject/Distributed-SGD/lua-lua/outputs/%s/ &> /dev/null' % (ip_addr, ip_addr)
os.system(cmd)
os._exit(0)
def main(arguments):
with open('../client_list.txt') as f:
if not os.path.exists('outputs'):
os.makedirs('outputs')
pids = []
for line in f:
# os.system('echo ' + line)
newpid = os.fork()
pids.append(newpid)
if newpid == 0:
if line[-1] == '\n':
child(line[:-1])
else:
child(line)
time.sleep(5)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))