sdk_script.py 1.4 KB

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