[tor-commits] [gettor/master] Refactor get_links script
hiro at torproject.org
hiro at torproject.org
Wed May 22 09:07:49 UTC 2019
commit 2e94e2651923b1de196732fcf266bba4dc7f3d12
Author: hiro <hiro at torproject.org>
Date: Wed May 22 11:07:39 2019 +0200
Refactor get_links script
---
scripts/add_lins_to_db | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/scripts/add_lins_to_db b/scripts/add_lins_to_db
index 62641f6..525a394 100755
--- a/scripts/add_lins_to_db
+++ b/scripts/add_lins_to_db
@@ -53,14 +53,13 @@ def main():
args = parser.parse_args()
abs_filename = os.path.abspath(args.filename)
- webFile = request.urlopen("https://lektor-staging.torproject.org/tpo/staging/projects/torbrowser/RecommendedTBBVersions/")
- versions = webFile.read().decode('utf-8')
- version = versions.split(""")[1]
+ webFile = request.urlopen("https://www.torproject.org/projects/torbrowser/RecommendedTBBVersions/")
+ versions = webFile.read().decode('utf-8').translate({ord(c): None for c in '[]\n" '})
+ version = versions.split(",")[4]
providers = {
- "osx": "https://gitlab.com/hiromipaw/torbrowser/raw/releases/",
- "windows": "https://gitlab.com/hiromipaw/torbrowser/raw/releases/",
- "linux": "https://gitlab.com/hiromipaw/torbrowser/raw/releases/"
+ "gitlab": "https://gitlab.com/thetorproject/gettorbrowser/raw/releases/",
+ "github": "https://github.com/TheTorProject/gettorbrowser/raw/torbrowser-releases/"
}
@@ -78,8 +77,8 @@ def main():
"linux": "_en-US.tar.xz"
}
- keys = set().union(suffixes, versions, prefixes)
- releases = {k: "".join(dic.get(k, version) for dic in (providers, prefixes, versions, suffixes)) for k in keys}
+ keys = {'osx', 'windows', 'linux'}
+ releases = {k: "".join(dic.get(k, version) for dic in (prefixes, versions, suffixes)) for k in keys}
if not abs_filename:
@@ -97,10 +96,11 @@ def main():
" version TEXT, provider TEXT, status TEXT)"
)
for k in keys:
- c.execute(
- "INSERT INTO links(link, platform, arch, version, provider, status)"
- "VALUES ('%s', '%s', '64', '%s', 'gitlab', 'ACTIVE')" %(releases.get(k), k, version)
- )
+ for p in providers:
+ c.execute(
+ "INSERT INTO links(link, platform, arch, version, provider, status)"
+ "VALUES ('%s', '%s', '64', '%s', '%s', 'ACTIVE')" %(providers.get(p) + releases.get(k), k, version, p))
+ )
if __name__ == "__main__":
More information about the tor-commits
mailing list