From 4c5cd1f847c41d554ed9b213a1bb2aefb616bdc3 Mon Sep 17 00:00:00 2001 From: jeremy <jeremy.bailleux@memgraph.io> Date: Mon, 31 Oct 2022 16:10:04 +0100 Subject: [PATCH] Add possibility to have MgBench working against local file --- tests/mgbench/helpers.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/mgbench/helpers.py b/tests/mgbench/helpers.py index 7488b1443..1a4cd3c3e 100644 --- a/tests/mgbench/helpers.py +++ b/tests/mgbench/helpers.py @@ -28,18 +28,25 @@ def get_binary_path(path, base=""): def download_file(url, path): - ret = subprocess.run(["wget", "-nv", "--content-disposition", url], - stderr=subprocess.PIPE, cwd=path, check=True) - data = ret.stderr.decode("utf-8") - tmp = data.split("->")[1] - name = tmp[tmp.index('"') + 1:tmp.rindex('"')] - return os.path.join(path, name) + if "https://" in url: + ret = subprocess.run( + ["wget", "-nv", "--content-disposition", url], stderr=subprocess.PIPE, cwd=path, check=True + ) + data = ret.stderr.decode("utf-8") + tmp = data.split("->")[1] + name = tmp[tmp.index('"') + 1 : tmp.rindex('"')] + return os.path.join(path, name) + else: + assert os.path.exists(url) + subprocess.run(["cp", url, path], stderr=subprocess.PIPE, cwd=path, check=True) + tmp = url.split("/") + name = tmp[len(tmp) - 1] + return os.path.join(path, name) def unpack_and_move_file(input_path, output_path): if input_path.endswith(".gz"): - subprocess.run(["gunzip", input_path], - stdout=subprocess.DEVNULL, check=True) + subprocess.run(["gunzip", input_path], stdout=subprocess.DEVNULL, check=True) input_path = input_path[:-3] os.rename(input_path, output_path)