TestWizardBLK.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # -*- coding:utf-8 -*-
  2. from ssat_sdk import sat_environment
  3. import sys,os
  4. from ConfigParser import *
  5. try:
  6. SAT_HOME = sat_environment.getSATRCUDIR()
  7. BlueToothDir = "bluetooth"
  8. TW_BLEK_Path = os.path.join(SAT_HOME,BlueToothDir,"TW_BLEK.ini")
  9. Home_Init = True
  10. except KeyError, e:
  11. print "KeyError:", e.message
  12. class BLKConfig():
  13. def __init__(self):
  14. if not os.path.exists(TW_BLEK_Path):
  15. print 'TW_BLEK.ini文件不存在,采用默认按键配置'
  16. self.CFGParser = ConfigParser()
  17. self.CFGParser.read(TW_BLEK_Path)
  18. '''
  19. 将TW_BLEK.ini配置中的所有案件加载到字典中。
  20. '''
  21. def loadBLEKey(self):
  22. section = "BLE_KEY"
  23. try:
  24. optionList = self.CFGParser.options(section)
  25. blkDic = {}
  26. for option in optionList:
  27. value = self.CFGParser.get(section, option)
  28. blkDic[option.lower()] = value
  29. return blkDic
  30. except Exception,e:
  31. print "TW_BLEK.ini配置异常"
  32. return None
  33. blkCFG = BLKConfig()
  34. BLK_DIC = blkCFG.loadBLEKey()
  35. if BLK_DIC is None:
  36. BLK_DIC = {
  37. #0C
  38. "mute":"0C00E2",
  39. "vol+":"0C00E9",
  40. "vol-":"0C00EA",
  41. "power":"0C0079",
  42. "ch+":"0C009C",
  43. "ch-":"0C009D",
  44. "home":"0C0223",
  45. "back":"0C0224",
  46. #07
  47. "rightarrow":"07004F",
  48. "leftarrow":"070050",
  49. "downarrow":"070051",
  50. "uparrow":"070052",
  51. "enter":"070028",
  52. "menu":"070065",
  53. "settings":"0700A8",
  54. "epg":"07008E"
  55. }
  56. # print "BLK_DIC:",BLK_DIC