conf.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import xml.etree.ElementTree as ET
  2. from logger import log
  3. class Config:
  4. 'Configuration Class for File Paths'
  5. Original_Path = ""
  6. Moved_Path = ""
  7. Dialogs = 0
  8. Trial = ""
  9. Share_Btn_X = 0
  10. Share_Btn_Y = 0
  11. Water_Mark_Btn_X = 0
  12. Water_Mark_Btn_Y = 0
  13. App_time = 0
  14. log = log()
  15. def read_config(self):
  16. log.logger.info('Reading configuration file')
  17. tree = ET.parse('configuration.xml')
  18. root = tree.getroot()
  19. #Get the folder path where the files are present
  20. path = root.find('Path')
  21. if path == "":
  22. log.logger.info('Failed to read the file path attribute')
  23. return 0
  24. Config.Original_Path = path.get('path1')
  25. if Config.Original_Path == "":
  26. log.logger.info('Failed to read the file path')
  27. return 0
  28. #Get the folder path where files are to be moved
  29. move_path = root.find('MovePath')
  30. if move_path == "":
  31. log.logger.info('Failed to read the copy file path attribute')
  32. return 0
  33. Config.Moved_Path = move_path.get('path2')
  34. if Config.Moved_Path == "":
  35. log.logger.info('Failed to read the copy file path')
  36. return 0
  37. #Get the no. of dialogs screens during coversion
  38. no_screens = root.find('No_Screens')
  39. if no_screens == "":
  40. log.logger.error('Failed to read the no. of dialog box attribute')
  41. return 0
  42. Config.Dialogs = no_screens.get('dialog')
  43. if Config.Dialogs == "":
  44. log.logger.error('Failed to read the no. of dialog boxes')
  45. return 0
  46. Config.Dialogs = int(Config.Dialogs)
  47. #Get if Camtasia has Trial license
  48. trial = root.find('TRIAL')
  49. if trial == "":
  50. log.logger.error('Failed to read the trial license attribute')
  51. return 0
  52. Config.Trial = trial.get('trial')
  53. if Config.Trial == "":
  54. log.logger.error('Failed to read the trial license value')
  55. return 0
  56. #Get the co-ordinates of the share button
  57. share_btn = root.find('Share_BTN_COOR')
  58. Config.Share_Btn_X = share_btn.get('x')
  59. Config.Share_Btn_X = int(Config.Share_Btn_X)
  60. Config.Share_Btn_Y = share_btn.get('y')
  61. Config.Share_Btn_Y = int(Config.Share_Btn_Y)
  62. #Get the co-ordinates Watermark
  63. watermark_btn = root.find('WATER_MARK_COOR')
  64. Config.Water_Mark_Btn_X = watermark_btn.get('x')
  65. Config.Water_Mark_Btn_X = int(Config.Water_Mark_Btn_X)
  66. Config.Water_Mark_Btn_Y = watermark_btn.get('y')
  67. Config.Water_Mark_Btn_Y = int(Config.Water_Mark_Btn_Y)
  68. #Get the sleep time for Camtasia app to start
  69. app_time = root.find('APP_START_TIME')
  70. Config.App_time = app_time.get('time')
  71. Config.App_time = int(Config.App_time)
  72. return 1
  73. def get_Moved_Path(self):
  74. return Config.Moved_Path
  75. def get_Original_Path(self):
  76. return Config.Original_Path