Created
September 7, 2016 03:01
-
-
Save 1davidmichael/34b6bc054ca0957c05ca09d78b9c1906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import datetime | |
import Queue | |
from threading import Thread | |
from subprocess import call | |
start_date = datetime.date(2015,10,10) | |
end_date = datetime.date.today() | |
delta = end_date - start_date | |
dates = [] | |
q = Queue.LifoQueue() | |
for i in range(delta.days +1): | |
dates.append(start_date + datetime.timedelta(days=i)) | |
for date in dates: | |
q.put(date.strftime('%Y%m%d')) | |
def grab_data_from_queue(): | |
while not q.empty(): | |
date_dir = q.get() | |
call(['rsync', '-rpg', '/nfs/mediastore001/%s/' % date_dir, '/storage/mediastore001/%s/' % date_dir]) | |
print('done with %s' % date_dir) | |
q.task_done() | |
for i in range(5): | |
t1 = Thread(target = grab_data_from_queue) | |
t1.start() | |
q.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment