jmunsch

example queue

Jul 14th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. import shutil
  2. import time
  3.  
  4. def createBackup(fn):
  5.     year = str(time.localtime()[0])
  6.     month = str(time.localtime()[1])
  7.     day = str(time.localtime()[2])
  8.     csv_fn = '_'.join(['backup',year,month,day,'verificationRequestsQueue.csv'])
  9.     shutil.copy(fn,csv_fn)
  10.     return
  11.  
  12. def return_lines(fn):
  13.     with open(fn,'r+') as f:
  14.         lines = f.read()
  15.     lines = lines.split('\n')
  16.     return lines
  17.    
  18. def write_lines(lines,fn):
  19.     with open(fn,'wb') as f:
  20.         for l in lines:
  21.             f.write(l+'\n')
  22.     return
  23.    
  24. def upload(lines):
  25.     runSelenium()
  26.     return
  27.  
  28.    
  29. fn = 'C:/path/to/queue.csv'
  30. createBackup(fn)
  31. lines = return_lines(fn)
  32. if len(lines) > 20:
  33.     upload_lines = lines[:20]
  34.     updated_queue = lines[21:]
  35.     upload(upload_lines)
  36.     write_lines(updated_queue)
  37. else:
  38.     upload_lines = lines
  39.     upload(upload_lines)
Advertisement
Add Comment
Please, Sign In to add comment