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.

29 lines
1.2 KiB

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