aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2019-03-19 10:29:40 +0000
committerPetr Štetiar <ynezz@true.cz>2019-07-26 08:09:16 +0200
commite785da815bcf5f83ae5337a396efeca2445eb8bd (patch)
treec5ea6337e8227b14ed59267919405d1ddf3d232b /scripts
parent5989a75cc455e09b79fe6880ba6bae6f6332cd24 (diff)
downloadupstream-e785da815bcf5f83ae5337a396efeca2445eb8bd.tar.gz
upstream-e785da815bcf5f83ae5337a396efeca2445eb8bd.tar.bz2
upstream-e785da815bcf5f83ae5337a396efeca2445eb8bd.zip
scripts/dl_github_archive.py: convert to Python 3 with 2-to-3
Let's convert the script to Python 3. Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dl_github_archive.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/dl_github_archive.py b/scripts/dl_github_archive.py
index 4bb7d131bb..671a7acfac 100755
--- a/scripts/dl_github_archive.py
+++ b/scripts/dl_github_archive.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (c) 2018 Yousong Zhou <yszhou4tech@gmail.com>
#
@@ -20,7 +20,7 @@ import ssl
import subprocess
import sys
import time
-import urllib2
+import urllib.request
TMPDIR = os.environ.get('TMP_DIR') or '/tmp'
TMPDIR_DL = os.path.join(TMPDIR, 'dl')
@@ -194,7 +194,7 @@ class GitHubCommitTsCache(object):
self.cache[k] = (ts, updated)
def _cache_flush(self, fout):
- cache = sorted(self.cache.iteritems(), cmp=lambda a, b: b[1][1] - a[1][1])
+ cache = sorted(self.cache.items(), key=lambda a: a[1][1])
cache = cache[:self.__cachen]
self.cache = {}
os.ftruncate(fout.fileno(), 0)
@@ -397,9 +397,9 @@ class DownloadGitHubTarball(object):
'Accept': 'application/vnd.github.v3+json',
'User-Agent': 'OpenWrt',
}
- req = urllib2.Request(url, headers=headers)
+ req = urllib.request.Request(url, headers=headers)
sslcontext = ssl._create_unverified_context()
- fileobj = urllib2.urlopen(req, context=sslcontext)
+ fileobj = urllib.request.urlopen(req, context=sslcontext)
return fileobj
def _error(self, msg):