From patchwork Mon Jun 17 20:08:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1117480 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TmTjq6Qj"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45SMkj6Qm1z9sBr for ; Tue, 18 Jun 2019 06:09:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1X3jvLQTnZ2alGKREE/pZnUiFy/lMe5mrXe28qhndd8=; b=TmTjq6QjZ/+QJv kQX1lFMbMNT/L3+ZmdFFz1H35TjHwzpaLu29mGwTuU/ShF4KdIGBnmW9flG61ONMDlh4/ufjJi5rO mIDs/gOKuJgLUw1HuaiXcVGHg+Yc5KjabA6WqiHGzw/pjShKEsyO/m72o3OIXYkhBt5fI8fP+FCgD BXZbpo+6NsGHRmX92OnyJAxKGV5WZHMwdtEvvgDSAX/jn9foj57Ee1kSDcXuiBVaJJ+sXggEfzGTk bS2o4eAYQZaVHtNpelso4hxlBcwwpeJexhyazZUqqGG484zXbFvB+tziP6i+KLRP8ix2+RoNxcu03 7nc4L9J3qbWwrdw8e4zQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hcxwg-0006lO-0U; Mon, 17 Jun 2019 20:09:38 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hcxwB-0006Hd-9v for openwrt-devel@lists.openwrt.org; Mon, 17 Jun 2019 20:09:10 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 1572A4FB4; Mon, 17 Jun 2019 22:09:05 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 3ea6c3e8; Mon, 17 Jun 2019 22:09:03 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Mon, 17 Jun 2019 22:08:52 +0200 Message-Id: <1560802136-4157-3-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1560802136-4157-1-git-send-email-ynezz@true.cz> References: <1560802136-4157-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190617_130907_514552_F3F35DAE X-CRM114-Status: UNSURE ( 8.09 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.217.244.18 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH 2/6] scripts/dl_github_archive.py: convert to Python 3 with 2-to-3 X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Let's convert the script to Python 3. Signed-off-by: Petr Štetiar --- scripts/dl_github_archive.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/dl_github_archive.py b/scripts/dl_github_archive.py index 4bb7d131bb83..3d1e07e5c551 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 # @@ -20,7 +20,7 @@ import ssl import subprocess import sys import time -import urllib2 +import urllib.request, urllib.error, urllib.parse 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(iter(self.cache.items()), cmp=lambda a, b: b[1][1] - 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):