Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import shutil
- import time
- def createBackup(fn):
- year = str(time.localtime()[0])
- month = str(time.localtime()[1])
- day = str(time.localtime()[2])
- csv_fn = '_'.join(['backup',year,month,day,'verificationRequestsQueue.csv'])
- shutil.copy(fn,csv_fn)
- return
- def return_lines(fn):
- with open(fn,'r+') as f:
- lines = f.read()
- lines = lines.split('\n')
- return lines
- def write_lines(lines,fn):
- with open(fn,'wb') as f:
- for l in lines:
- f.write(l+'\n')
- return
- def upload(lines):
- runSelenium()
- return
- fn = 'C:/path/to/queue.csv'
- createBackup(fn)
- lines = return_lines(fn)
- if len(lines) > 20:
- upload_lines = lines[:20]
- updated_queue = lines[21:]
- upload(upload_lines)
- write_lines(updated_queue)
- else:
- upload_lines = lines
- upload(upload_lines)
Advertisement
Add Comment
Please, Sign In to add comment