app.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from automate import Automate
  2. from BussinessLogic import business_logic
  3. from conf import Config
  4. from logger import log
  5. import sys
  6. import os, time
  7. log = log()
  8. Auto = Automate()
  9. path_to_watch = "E:/testserver"
  10. before = dict ([(f, None) for f in os.listdir (path_to_watch)])
  11. while 1:
  12. time.sleep (10)
  13. after = dict ([(f, None) for f in os.listdir (path_to_watch)])
  14. added = [f for f in after if not f in before]
  15. removed = [f for f in before if not f in after]
  16. if added:
  17. print "Added: ", ", ".join (added)
  18. #if removed: print "Removed: ", ", ".join (removed)
  19. #before = after
  20. #Globals
  21. Files=[]
  22. #Initializes from the configuration file
  23. log.logger.info('Initialization called')
  24. status = Auto.Init()
  25. if status == 0:
  26. log.logger.error('Initialization failed.Exiting application')
  27. Path = Config()
  28. #Copy the files from src path to dest path inorder to create a backup
  29. status = Auto.copyFiles(Path.Original_Path,Path.Moved_Path,added)
  30. if status == 0:
  31. log.logger.error('Copying files failed. Exiting Application')
  32. sys.exit(0)
  33. else:
  34. log.logger.info('File copy successfull')
  35. #Get the files from the dest folder to start the conversion process
  36. Files=Auto.GetFiles(Path.Moved_Path)
  37. bi = business_logic()
  38. for file in Files:
  39. status = bi.convert_files(file)
  40. if status == 1:
  41. print "Rendering Succesfull!!"
  42. before = after