| |
@@ -52,8 +52,9 @@
|
| |
self.log.debug(header + ": " + str(cmd))
|
| |
if isinstance(cmd, str) and not shell:
|
| |
cmd = cmd.split(" ")
|
| |
- proc = Popen(cmd, stdout=PIPE, stderr=PIPE,
|
| |
- universal_newlines=True, shell=shell)
|
| |
+ proc = Popen(
|
| |
+ cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True, shell=shell
|
| |
+ )
|
| |
|
| |
output, error = "", "undefined"
|
| |
try:
|
| |
@@ -85,8 +86,10 @@
|
| |
import socket
|
| |
|
| |
socket.setdefaulttimeout(30)
|
| |
-
|
| |
- istream = urllib.request.urlopen(url)
|
| |
+ req = urllib.request.Request(
|
| |
+ url=url, headers={"User-Agent": "fedora-review"}
|
| |
+ )
|
| |
+ istream = urllib.request.urlopen(req)
|
| |
if istream.getcode() and istream.getcode() != 200:
|
| |
raise DownloadError(istream.getcode(), url)
|
| |
with open(path, "wb") as ostream:
|
| |
While working on a package at https://bugzilla.redhat.com/show_bug.cgi?id=2334903 I encountered download failures using fedora-review. Which produced warnings for the fedora-review output and resulted in being unable to check the checksums for upstream sources matched what was bundled in the srpm.
This ended up being because cloudflare blocks requests with
User-Agent: Python-urllib/3.13and the upstream archives were hosted using cloudflare R2.A small example of this is.
This can also be tested on the
https://www.cloudflare.comurland reproduced with curl using the urllib User-Agent
curl -vvv -A "Python-urllib/3.13" http://www.cloudflare.comA solution is to override this header with a different User-Agent header when making the request.
I ran the
black,make pycodestyleandmake flake8commands as described inCONTRIBUTE.