sdk_script.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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['properties'])
  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, propValue):
  25. '''
  26. 创建jmhy.properties
  27. '''
  28. print('create jmhy.properties')
  29. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel)
  30. properties = os.path.join(decompliePath, 'assets', 'jmhy.properties')
  31. content = ''
  32. for key in propValue:
  33. content = '%s%s=%s\n' % (content, key, propValue[key])
  34. file_utils.createFile(properties, content)
  35. return 0