sdk_script.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import file_utils
  2. import xml_utils
  3. import common_utils
  4. import os.path
  5. encoding = 'UTF-8'
  6. namespaces = {'android' : 'http://schemas.android.com/apk/res/android'}
  7. import xml.etree.ElementTree as ET
  8. def execute(game, sdk, config):
  9. if not checkConfig(config):
  10. return 1
  11. subChannel = config['subChannel']
  12. createJmhyProperties(game, sdk, subChannel, config)
  13. return 0
  14. def checkConfig(config):
  15. '''
  16. 检查配置
  17. '''
  18. if 'properties' not in config:
  19. print('properties not exists in config')
  20. return False
  21. properties = config['properties']
  22. if 'agent' not in properties or 'version' not in properties:
  23. print('agent or version not exists in properties')
  24. return False
  25. '''if 'appid' not in config or 'appkey' not in config:
  26. print('appid or appkey not exists in config')
  27. return False'''
  28. return True
  29. def createJmhyProperties(game, sdk, subChannel, config):
  30. '''
  31. 创建jmhy.properties
  32. '''
  33. print('create jmhy.properties')
  34. propValue = config['properties']
  35. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  36. properties = os.path.join(decompliePath, 'assets', 'jmhy.properties')
  37. content = ''
  38. for key in propValue:
  39. content = '%s%s=%s\n' % (content, key, propValue[key])
  40. file_utils.createFile(properties, content)
  41. return 0