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. return createJmhyProperties(game, sdk, subChannel, config)
  8. def checkConfig(config):
  9. '''
  10. 检查配置
  11. '''
  12. if 'properties' not in config:
  13. print('properties not exists in config')
  14. return False
  15. properties = config['properties']
  16. if 'agent' not in properties or 'version' not in properties:
  17. print('agent or version not exists in properties')
  18. return False
  19. '''if 'appid' not in config or 'appkey' not in config:
  20. print('appid or appkey not exists in config')
  21. return False'''
  22. return True
  23. def createJmhyProperties(game, sdk, subChannel, config):
  24. '''
  25. 创建jmhy.properties
  26. '''
  27. print('create jmhy.properties')
  28. propValue = config['properties']
  29. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  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