sdk_script.py 1.3 KB

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