sdk_script.py 1.3 KB

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