conf.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #This file is for reading the configuration.xml
  2. import xml.etree.ElementTree as ET
  3. from logger import log
  4. class Config:
  5. 'Configuration Class for File Paths'
  6. Original_Path = ""
  7. Camtasia_Path = ""
  8. App_Name = ""
  9. Saved_Path = ""
  10. Dialogs = 0
  11. Trial = ""
  12. Share_Btn_X = 0
  13. Share_Btn_Y = 0
  14. Water_Mark_Btn_X = 0
  15. Water_Mark_Btn_Y = 0
  16. App_time = 0
  17. Dialog_wait_time = 0
  18. Rendering_wait_time = 0
  19. Polling_time = 0
  20. log = log()
  21. #Function to read the configuration.xml
  22. def read_config(self):
  23. log.logger.info('Reading configuration file')
  24. tree = ET.parse('configuration.xml')
  25. root = tree.getroot()
  26. #Get the folder path where the files are present
  27. path = root.find('WatchFolder')
  28. if path == "":
  29. log.logger.info('Failed to read the file path attribute')
  30. return 0
  31. Config.Original_Path = path.get('path1')
  32. if Config.Original_Path == "":
  33. log.logger.info('Failed to read the file path')
  34. return 0
  35. #Get the folder path where files are to be moved
  36. camtasia_path = root.find('CamtasiaPath')
  37. if camtasia_path == "":
  38. log.logger.info('Failed to read the Camtasia file path attribute')
  39. return 0
  40. Config.Camtasia_Path = camtasia_path.get('path2')
  41. if Config.Camtasia_Path == "":
  42. log.logger.info('Failed to read the Camtasia file path')
  43. return 0
  44. app_name = root.find('APP_NAME')
  45. if app_name == "":
  46. log.logger.info('Failed to read the App name attribute')
  47. return 0
  48. Config.App_Name = app_name.get('app_name')
  49. if Config.App_Name == "":
  50. log.logger.info('Failed to read App name')
  51. return 0
  52. #Get the folder path where files are to be saved after rendering
  53. saved_path = root.find('SAVING_PATH')
  54. if saved_path == "":
  55. log.logger.info('Failed to read the saved file path attribute')
  56. return 0
  57. Config.Saved_Path = saved_path.get('path3')
  58. if Config.Saved_Path == "":
  59. log.logger.info('Failed to read the saving path')
  60. return 0
  61. #Get the no. of dialogs screens during coversion
  62. no_screens = root.find('No_Screens')
  63. if no_screens == "":
  64. log.logger.error('Failed to read the no. of dialog box attribute')
  65. return 0
  66. Config.Dialogs = no_screens.get('dialog')
  67. if Config.Dialogs == "":
  68. log.logger.error('Failed to read the no. of dialog boxes')
  69. return 0
  70. Config.Dialogs = int(Config.Dialogs)
  71. #Get if Camtasia has Trial license
  72. trial = root.find('TRIAL')
  73. if trial == "":
  74. log.logger.error('Failed to read the trial license attribute')
  75. return 0
  76. Config.Trial = trial.get('trial')
  77. if Config.Trial == "":
  78. log.logger.error('Failed to read the trial license value')
  79. return 0
  80. #Get the co-ordinates of the share button
  81. share_btn = root.find('Share_BTN_COOR')
  82. Config.Share_Btn_X = share_btn.get('x')
  83. Config.Share_Btn_X = int(Config.Share_Btn_X)
  84. Config.Share_Btn_Y = share_btn.get('y')
  85. Config.Share_Btn_Y = int(Config.Share_Btn_Y)
  86. #Get the co-ordinates Watermark
  87. watermark_btn = root.find('WATER_MARK_COOR')
  88. Config.Water_Mark_Btn_X = watermark_btn.get('x')
  89. Config.Water_Mark_Btn_X = int(Config.Water_Mark_Btn_X)
  90. Config.Water_Mark_Btn_Y = watermark_btn.get('y')
  91. Config.Water_Mark_Btn_Y = int(Config.Water_Mark_Btn_Y)
  92. #Get the sleep time for Camtasia app to start
  93. app_time = root.find('APP_START_TIME')
  94. Config.App_time = app_time.get('time')
  95. Config.App_time = int(Config.App_time)
  96. #Get the wait time for Dialog box
  97. dialog_wait_time = root.find('DIALOG_WAIT_TIME')
  98. Config.Dialog_wait_time = dialog_wait_time.get('time2')
  99. Config.Dialog_wait_time = float(Config.Dialog_wait_time)
  100. #Get the rendering wait time
  101. rendering_wait_time = root.find('REND_WAIT_TIME')
  102. Config.Rendering_wait_time = rendering_wait_time.get('time3')
  103. Config.Rendering_wait_time = float(Config.Rendering_wait_time)
  104. #Get the watch folder polling time
  105. polling_time = root.find('POLLING_TIME')
  106. Config.Polling_time = polling_time.get('time4')
  107. Config.Polling_time = int(Config.Polling_time)
  108. return 1
  109. def get_Moved_Path(self):
  110. return Config.Moved_Path
  111. def get_Original_Path(self):
  112. return Config.Original_Path