conf.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. log = log()
  14. def read_config(self):
  15. log.logger.info('Reading configuration file')
  16. tree = ET.parse('configuration.xml')
  17. root = tree.getroot()
  18. #Get the folder path where the files are present
  19. path = root.find('Path')
  20. if path == "":
  21. log.logger.info('Failed to read the file path attribute')
  22. return 0
  23. Config.Original_Path = path.get('path1')
  24. if Config.Original_Path == "":
  25. log.logger.info('Failed to read the file path')
  26. return 0
  27. #Get the folder path where files are to be moved
  28. move_path = root.find('MovePath')
  29. if move_path == "":
  30. log.logger.info('Failed to read the copy file path attribute')
  31. return 0
  32. Config.Moved_Path = move_path.get('path2')
  33. if Config.Moved_Path == "":
  34. log.logger.info('Failed to read the copy file path')
  35. return 0
  36. #Get the no. of dialogs screens during coversion
  37. no_screens = root.find('No_Screens')
  38. if no_screens == "":
  39. log.logger.error('Failed to read the no. of dialog box attribute')
  40. return 0
  41. Config.Dialogs = no_screens.get('dialog')
  42. if Config.Dialogs == "":
  43. log.logger.error('Failed to read the no. of dialog boxes')
  44. return 0
  45. Config.Dialogs = int(Config.Dialogs)
  46. #Get if Camtasia has Trial license
  47. trial = root.find('TRIAL')
  48. if trial == "":
  49. log.logger.error('Failed to read the trial license attribute')
  50. return 0
  51. Config.Trial = trial.get('trial')
  52. if Config.Trial == "":
  53. log.logger.error('Failed to read the trial license value')
  54. return 0
  55. #Get the co-ordinates of the share button
  56. share_btn = root.find('Share_BTN_COOR')
  57. Config.Share_Btn_X = share_btn.get('x')
  58. Config.Share_Btn_X = int(Config.Share_Btn_X)
  59. Config.Share_Btn_Y = share_btn.get('y')
  60. Config.Share_Btn_Y = int(Config.Share_Btn_Y)
  61. #Get the co-ordinates Watermark
  62. watermark_btn = root.find('WATER_MARK_COOR')
  63. Config.Water_Mark_Btn_X = watermark_btn.get('x')
  64. Config.Water_Mark_Btn_X = int(Config.Water_Mark_Btn_X)
  65. Config.Water_Mark_Btn_Y = watermark_btn.get('y')
  66. Config.Water_Mark_Btn_Y = int(Config.Water_Mark_Btn_Y)
  67. return 1
  68. def get_Moved_Path(self):
  69. return Config.Moved_Path
  70. def get_Original_Path(self):
  71. return Config.Original_Path