automate.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from conf import Config
  2. import os
  3. import shutil
  4. from logger import log
  5. class Automate:
  6. #Initialization Class for Automation
  7. log = log()
  8. def Init(self):
  9. __configuration__ = Config()
  10. status = __configuration__.read_config()
  11. if status == 0:
  12. return 0
  13. return 1
  14. def GetFiles(self, paths):
  15. files = []
  16. for file in os.listdir(paths):
  17. files.append(file)
  18. return files
  19. def copyFiles(self, src_folder,dest_folder):
  20. if src_folder == "" or dest_folder == "":
  21. log.logger.error('Source or Destination Folder does not exists')
  22. return 0
  23. if not os.listdir(src_folder):
  24. log.logger.error('No files found in src folder')
  25. return 0
  26. for file in os.listdir(src_folder):
  27. print ("File being moved -----> " + file)
  28. full_file_name = os.path.join( src_folder, file )
  29. if os.path.isfile(full_file_name):
  30. try:
  31. shutil.copy( full_file_name, dest_folder )
  32. except shutil.Error as e:
  33. log.logger.error('Could not copy the files %s',e)
  34. return 0
  35. return 1