2015-12-19 03:57:09 -08:00
|
|
|
#!/usr/bin/python2
|
2013-04-13 09:50:17 -07:00
|
|
|
import sys
|
2015-03-03 03:28:33 -08:00
|
|
|
import re
|
2013-11-12 21:11:22 -08:00
|
|
|
import hashlib
|
|
|
|
import os
|
2013-04-13 09:50:17 -07:00
|
|
|
|
2017-01-03 02:40:34 -08:00
|
|
|
from versions import version, version_win, version_mac, version_android, version_apk
|
2015-02-24 09:41:29 -08:00
|
|
|
from versions import download_template, download_page
|
2013-04-13 09:50:17 -07:00
|
|
|
|
2015-02-24 09:41:29 -08:00
|
|
|
with open(download_template) as f:
|
2013-11-23 06:47:00 -08:00
|
|
|
string = f.read()
|
2013-11-12 21:11:22 -08:00
|
|
|
|
2013-04-13 09:50:17 -07:00
|
|
|
string = string.replace("##VERSION##", version)
|
|
|
|
string = string.replace("##VERSION_WIN##", version_win)
|
|
|
|
string = string.replace("##VERSION_MAC##", version_mac)
|
2017-01-03 02:40:34 -08:00
|
|
|
string = string.replace("##VERSION_ANDROID##", version_android)
|
2016-03-06 05:49:50 -08:00
|
|
|
string = string.replace("##VERSION_APK##", version_apk)
|
2015-03-03 03:28:33 -08:00
|
|
|
|
|
|
|
files = {
|
|
|
|
'tgz': "Electrum-%s.tar.gz" % version,
|
|
|
|
'zip': "Electrum-%s.zip" % version,
|
|
|
|
'mac': "electrum-%s.dmg" % version_mac,
|
|
|
|
'win': "electrum-%s.exe" % version_win,
|
|
|
|
'win_setup': "electrum-%s-setup.exe" % version_win,
|
|
|
|
'win_portable': "electrum-%s-portable.exe" % version_win,
|
|
|
|
}
|
|
|
|
|
|
|
|
for k, n in files.items():
|
2015-10-28 16:15:13 -07:00
|
|
|
path = "dist/%s"%n
|
|
|
|
link = "https://download.electrum.org/%s/%s"%(version,n)
|
2015-03-03 03:28:33 -08:00
|
|
|
if not os.path.exists(path):
|
|
|
|
os.system("wget -q %s -O %s" % (link, path))
|
2015-03-16 04:17:41 -07:00
|
|
|
if not os.path.getsize(path):
|
2015-03-03 03:28:33 -08:00
|
|
|
os.unlink(path)
|
|
|
|
string = re.sub("<div id=\"%s\">(.*?)</div>"%k, '', string, flags=re.DOTALL + re.MULTILINE)
|
2015-03-16 04:17:41 -07:00
|
|
|
continue
|
|
|
|
sigpath = path + '.asc'
|
|
|
|
siglink = link + '.asc'
|
|
|
|
if not os.path.exists(sigpath):
|
|
|
|
os.system("wget -q %s -O %s" % (siglink, sigpath))
|
|
|
|
if not os.path.getsize(sigpath):
|
|
|
|
os.unlink(sigpath)
|
|
|
|
string = re.sub("<div id=\"%s\">(.*?)</div>"%k, '', string, flags=re.DOTALL + re.MULTILINE)
|
|
|
|
continue
|
|
|
|
if os.system("gpg --verify %s"%sigpath) != 0:
|
2015-03-28 07:42:04 -07:00
|
|
|
raise BaseException(sigpath)
|
2015-03-16 04:17:41 -07:00
|
|
|
string = string.replace("##link_%s##"%k, link)
|
2015-03-03 03:28:33 -08:00
|
|
|
|
2013-04-13 09:50:17 -07:00
|
|
|
|
2015-02-24 09:41:29 -08:00
|
|
|
with open(download_page,'w') as f:
|
2013-11-23 06:47:00 -08:00
|
|
|
f.write(string)
|
|
|
|
|
2015-02-24 09:41:29 -08:00
|
|
|
|