|
|
eda038 |
From 7b0db90c76c6b0de6a4d481e63450e8f0d1a1d9d Mon Sep 17 00:00:00 2001
|
|
|
eda038 |
From: =?UTF-8?q?Ond=C5=99ej=20Budai?= <obudai@redhat.com>
|
|
|
eda038 |
Date: Thu, 25 Jun 2020 09:56:30 +0200
|
|
|
eda038 |
Subject: [PATCH] sources/files: do not pass floats to --max-time
|
|
|
eda038 |
|
|
|
eda038 |
curl uses strtod from the C standard library to convert the --max-time's value
|
|
|
eda038 |
from string to double. However, this is what strtod expects:
|
|
|
eda038 |
|
|
|
eda038 |
nonempty sequence of decimal digits optionally containing decimal-point
|
|
|
eda038 |
character (as determined by the current C locale)
|
|
|
eda038 |
|
|
|
eda038 |
Yeah, unfortunately, the decimal-point character is determined by the current
|
|
|
eda038 |
C locale. For example, Czech and German locale uses a comma as the
|
|
|
eda038 |
decimal-point character.
|
|
|
eda038 |
|
|
|
eda038 |
For reasons I don't fully understand, Python thinks it's running on en_US
|
|
|
eda038 |
locale, even though LC_NUMERIC is set to cs_CZ, so it uses a full stop as the
|
|
|
eda038 |
decimal-point character when converting float to string. However, as written
|
|
|
eda038 |
before, curl fails to parse this because it expects comma.
|
|
|
eda038 |
|
|
|
eda038 |
The fix I chose is simple: Use math.ceil, so only an integer can be passed to
|
|
|
eda038 |
curl. Why ceil? Because --max-time == 0 sounds fishy. math.ceil should return
|
|
|
eda038 |
an integer (and it does in Python 3.8) but the documentation is not 100% clear
|
|
|
eda038 |
on this topic, so let's be paranoid and also convert it to int after the
|
|
|
eda038 |
ceiling.
|
|
|
eda038 |
---
|
|
|
eda038 |
sources/org.osbuild.files | 3 ++-
|
|
|
eda038 |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
eda038 |
|
|
|
eda038 |
diff --git a/sources/org.osbuild.files b/sources/org.osbuild.files
|
|
|
eda038 |
index 42ff6ca..13ce9b8 100755
|
|
|
eda038 |
--- a/sources/org.osbuild.files
|
|
|
eda038 |
+++ b/sources/org.osbuild.files
|
|
|
eda038 |
@@ -17,6 +17,7 @@ import concurrent.futures
|
|
|
eda038 |
import glob
|
|
|
eda038 |
import itertools
|
|
|
eda038 |
import json
|
|
|
eda038 |
+import math
|
|
|
eda038 |
import os
|
|
|
eda038 |
import subprocess
|
|
|
eda038 |
import sys
|
|
|
eda038 |
@@ -102,7 +103,7 @@ def fetch(url, checksum, directory):
|
|
|
eda038 |
curl_command = [
|
|
|
eda038 |
"curl",
|
|
|
eda038 |
"--silent",
|
|
|
eda038 |
- "--max-time", f"{300 - elapsed_time}",
|
|
|
eda038 |
+ "--max-time", f"{int(math.ceil(300 - elapsed_time))}",
|
|
|
eda038 |
"--connect-timeout", "60",
|
|
|
eda038 |
"--fail",
|
|
|
eda038 |
"--location",
|
|
|
eda038 |
--
|
|
|
eda038 |
2.26.2
|
|
|
eda038 |
|