9 def __init__(self, pwfile):
11 self.cmd = ['/usr/bin/rsync', '--dry-run', '-a', ]
12 self.cmd.append('--password-file=%s' % (pwfile))
13 self.source_base = 'rsync://sequencer@jumpgate.caltech.edu:8730/sequencer/'
14 self.dest_base = '/home/diane/gec/'
19 """Get a directory listing"""
21 args = copy.copy(self.cmd)
22 args.append(self.source_base)
24 short_process = subprocess.Popen(args, stdout=subprocess.PIPE)
25 direntries = [ x.split() for x in short_process.stdout ]
26 for permissions, size, filedate, filetime, filename in direntries:
27 #print permissions, filename
28 if permissions[0] == 'd':
29 # hey its a directory, the first step to being something we want to
31 if re.match("[0-9]{6}", filename):
32 # it starts with something that looks like a 6 digit date
33 # aka good enough for me
34 dirs_to_copy.append(filename)
37 def create_copy_process(self, dirname):
38 args = copy.copy(self.cmd)
39 args.append(os.path.join(self.source_base, dirname))
40 args.append(self.dest_base)
41 return subprocess.Popen(args)
44 """copy any interesting looking directories over
46 dirs_to_copy = self.list()
47 for d in dirs_to_copy:
48 process = self.processes.get(d, None)
50 # we don't have a process, so make one
51 print "starting rsync", d
52 self.processes[d] = self.create_copy_process(d)
54 retcode = process.poll()
55 if retcode is not None:
57 print "rsync",d,"exited with state", retcode
60 if __name__ == "__main__":
61 r = rsync('/home/diane/.sequencer')
63 while len(r.processes) > 0: