You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.0 KiB

  1. #!/usr/bin/env python3
  2. from __future__ import unicode_literals
  3. import hashlib
  4. import urllib.request
  5. import json
  6. versions_info = json.load(open('update/versions.json'))
  7. version = versions_info['latest']
  8. URL = versions_info['versions'][version]['bin'][0]
  9. data = urllib.request.urlopen(URL).read()
  10. # Read template page
  11. with open('download.html.in', 'r', encoding='utf-8') as tmplf:
  12. template = tmplf.read()
  13. sha256sum = hashlib.sha256(data).hexdigest()
  14. template = template.replace('@PROGRAM_VERSION@', version)
  15. template = template.replace('@PROGRAM_URL@', URL)
  16. template = template.replace('@PROGRAM_SHA256SUM@', sha256sum)
  17. template = template.replace('@EXE_URL@', versions_info['versions'][version]['exe'][0])
  18. template = template.replace('@EXE_SHA256SUM@', versions_info['versions'][version]['exe'][1])
  19. template = template.replace('@TAR_URL@', versions_info['versions'][version]['tar'][0])
  20. template = template.replace('@TAR_SHA256SUM@', versions_info['versions'][version]['tar'][1])
  21. with open('download.html', 'w', encoding='utf-8') as dlf:
  22. dlf.write(template)