qlever 0.5.12__py3-none-any.whl → 0.5.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of qlever might be problematic. Click here for more details.

qlever/util.py CHANGED
@@ -3,9 +3,9 @@ from __future__ import annotations
3
3
  import errno
4
4
  import re
5
5
  import secrets
6
- import socket
7
6
  import shlex
8
7
  import shutil
8
+ import socket
9
9
  import string
10
10
  import subprocess
11
11
  from datetime import date, datetime
@@ -30,8 +30,11 @@ def get_total_file_size(patterns: list[str]) -> int:
30
30
 
31
31
 
32
32
  def run_command(
33
- cmd: str, return_output: bool = False, show_output: bool = False
34
- ) -> Optional[str]:
33
+ cmd: str,
34
+ return_output: bool = False,
35
+ show_output: bool = False,
36
+ use_popen: bool = False,
37
+ ) -> Optional[str | subprocess.Popen]:
35
38
  """
36
39
  Run the given command and throw an exception if the exit code is non-zero.
37
40
  If `return_output` is `True`, return what the command wrote to `stdout`.
@@ -41,6 +44,7 @@ def run_command(
41
44
 
42
45
  TODO: Find the executable for `bash` in `__init__.py`.
43
46
  """
47
+
44
48
  subprocess_args = {
45
49
  "executable": shutil.which("bash"),
46
50
  "shell": True,
@@ -48,17 +52,21 @@ def run_command(
48
52
  "stdout": None if show_output else subprocess.PIPE,
49
53
  "stderr": subprocess.PIPE,
50
54
  }
55
+
56
+ # With `Popen`, the command runs in the current shell and a process object
57
+ # is returned (which can be used, e.g., to kill the process).
58
+ if use_popen:
59
+ if return_output:
60
+ raise Exception("Cannot return output if `use_popen` is `True`")
61
+ return subprocess.Popen(f"set -o pipefail; {cmd}", **subprocess_args)
62
+
63
+ # With `run`, the command runs in a subshell and the output is captured.
51
64
  result = subprocess.run(f"set -o pipefail; {cmd}", **subprocess_args)
65
+
52
66
  # If the exit code is non-zero, throw an exception. If something was
53
67
  # written to `stderr`, use that as the exception message. Otherwise, use a
54
68
  # generic message (which is also what `subprocess.run` does with
55
69
  # `check=True`).
56
- # log.debug(f"Command `{cmd}` returned the following result")
57
- # log.debug("")
58
- # log.debug(f"exit code: {result.returncode}")
59
- # log.debug(f"stdout: {result.stdout}")
60
- # log.debug(f"stderr: {result.stderr}")
61
- # log.debug("")
62
70
  if result.returncode != 0:
63
71
  if len(result.stderr) > 0:
64
72
  raise Exception(result.stderr.replace("\n", " ").strip())
@@ -99,7 +107,11 @@ def run_curl_command(
99
107
  )
100
108
  )
101
109
  result = subprocess.run(
102
- curl_cmd, shell=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
110
+ curl_cmd,
111
+ shell=True,
112
+ text=True,
113
+ stdout=subprocess.PIPE,
114
+ stderr=subprocess.PIPE,
103
115
  )
104
116
  # Case 1: An error occurred, raise an exception.
105
117
  if result.returncode != 0:
@@ -120,18 +132,23 @@ def run_curl_command(
120
132
  return result.stdout
121
133
 
122
134
 
123
- def is_qlever_server_alive(port: str) -> bool:
135
+ def is_qlever_server_alive(endpoint_url: str) -> bool:
124
136
  """
125
137
  Helper function that checks if a QLever server is running on the given
126
- port.
138
+ endpoint. Return `True` if the server is alive, `False` otherwise.
127
139
  """
128
140
 
129
- message = "from the qlever script".replace(" ", "%20")
130
- curl_cmd = f"curl -s http://localhost:{port}/ping?msg={message}"
131
- exit_code = subprocess.call(
132
- curl_cmd, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
141
+ message = "from the `qlever` CLI"
142
+ curl_cmd = (
143
+ f"curl -s {endpoint_url}/ping"
144
+ f" --data-urlencode msg={shlex.quote(message)}"
133
145
  )
134
- return exit_code == 0
146
+ log.debug(curl_cmd)
147
+ try:
148
+ run_command(curl_cmd)
149
+ return True
150
+ except Exception:
151
+ return False
135
152
 
136
153
 
137
154
  def get_existing_index_files(basename: str) -> list[str]:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: qlever
3
- Version: 0.5.12
3
+ Version: 0.5.17
4
4
  Summary: Script for using the QLever SPARQL engine.
5
5
  Author-email: Hannah Bast <bast@cs.uni-freiburg.de>
6
6
  License: Apache-2.0
@@ -0,0 +1,54 @@
1
+ qlever/__init__.py,sha256=7VKA8tp5iHZQyTXhDOcxUbloZ7WyxDnkruq0iJOzQcE,1403
2
+ qlever/command.py,sha256=yOr0Uc8D8-AM7EjwDsVzbc3KNYjPH-FVOZhIHkqO588,2749
3
+ qlever/config.py,sha256=qYPy-MQ7BwGrvKSazQWhs0lnlOFqm-d47mpZhc3fptc,10254
4
+ qlever/containerize.py,sha256=bnHmjKIFEe-NcuAMRNnXAFjRVLcLnk9f5JspCCyhgt8,5210
5
+ qlever/log.py,sha256=2O_RvFymnu_dB10ErBTAOsI8bgjORfdD0tE3USH-siM,1315
6
+ qlever/qlever_main.py,sha256=-E4W8YdZ_teszGwXu6bQgBcH3y47TFJU8JLPIDwc_-g,2449
7
+ qlever/qlever_old.py,sha256=X-JxmepFKYeFgSLLp0TRDNqXSxDwIbc8_0Xstiems8c,62026
8
+ qlever/qleverfile.py,sha256=lygAjI5_wV_e-JoIGIqVTdd4yyvApzZiSlqSsmdlJpU,14529
9
+ qlever/util.py,sha256=xAK9GT8SgU3z65F1dFXazxsd60letqLQqQAZ81mdJSY,8374
10
+ qlever/Qleverfiles/Qleverfile.dblp,sha256=RaTJrabloAdaHwSl5V7Ws9phWyM_oXPSeZpKodZXA6c,1256
11
+ qlever/Qleverfiles/Qleverfile.dblp-plus,sha256=TJHxp8I1P6JKJjbuAllEpB32-huuY1gH0FlenqPVJ5g,1334
12
+ qlever/Qleverfiles/Qleverfile.dbpedia,sha256=aaNZZayE-zVePGSwPzXemkX__Ns8-kP_E7DNNKZPnqg,1160
13
+ qlever/Qleverfiles/Qleverfile.default,sha256=Kj-J1Kkv8PWN7wuMdZU6DUUlEuBIcSNysJCE-R63we8,2407
14
+ qlever/Qleverfiles/Qleverfile.dnb,sha256=43w_CVi00yf7FHdDvBtHHQR3yU1d-JCNnD_uxYZJOvk,1803
15
+ qlever/Qleverfiles/Qleverfile.fbeasy,sha256=9dwCMltT0BIMN4LRmaZFp1a7aV0kh0nJ9XLiQb_NJNo,940
16
+ qlever/Qleverfiles/Qleverfile.freebase,sha256=eFMOxeyuWVbb06Gv2-VFkuKE5tTyckddTDHdw5wbZN8,1028
17
+ qlever/Qleverfiles/Qleverfile.imdb,sha256=1xUBFimgnEHKP_o6tlqwJvIVpEE4Zx6UK_JnnQsG7Ew,1638
18
+ qlever/Qleverfiles/Qleverfile.ohm-planet,sha256=yG6NgW6x6sGTzmCi1wEAkQ-i9goTj2u3PQxvCUwjExs,2122
19
+ qlever/Qleverfiles/Qleverfile.olympics,sha256=5w9BOFwEBhdSzPz-0LRxwhv-7Gj6xbF539HOXr3cqD0,1088
20
+ qlever/Qleverfiles/Qleverfile.orkg,sha256=Uizz-RhlSeExgfckWztewa4l_v3zMN8IR7NaGYKrqt4,937
21
+ qlever/Qleverfiles/Qleverfile.osm-country,sha256=Pb9o5H3b7wVlVRgdiPHWCvrnkIRS1YUhxOazbUmoKZE,1897
22
+ qlever/Qleverfiles/Qleverfile.osm-planet,sha256=555aaMOIzAILvzwpCjucd_GE7TlYxmT2Qh8hME68stU,1418
23
+ qlever/Qleverfiles/Qleverfile.pubchem,sha256=ooSj2gqTzbGY_pMCvfL-MfE7Z0d5hQB4_EF5Pp2Mn6M,14465
24
+ qlever/Qleverfiles/Qleverfile.scientists,sha256=9eZ2c6P9a3E3VHa3RR7LdOQbF4k3oyyrn56Z3u4LZYs,1164
25
+ qlever/Qleverfiles/Qleverfile.uniprot,sha256=Yejez7uel9Vp8e4w-fI8-qLSqWyDUvjlq33gpebVC5k,6329
26
+ qlever/Qleverfiles/Qleverfile.vvz,sha256=cLzm85erKoFCDllH5eFcSi35MdR6Tahj1MgtvGRxanM,922
27
+ qlever/Qleverfiles/Qleverfile.wikidata,sha256=zVUXF75XJyK1h-J-7EjFemzmkSyoPtng1mNY3U7S78M,2061
28
+ qlever/Qleverfiles/Qleverfile.wikipathways,sha256=UFEVLrtOBiSQfibBN9xc2wDXrnWcnx5f8PY9khcE6bc,1983
29
+ qlever/Qleverfiles/Qleverfile.yago-4,sha256=hAS_2ZmC1zxNsKXip7t1F_iqu3CC-6O7v6HZhuFbnWY,1819
30
+ qlever/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
+ qlever/commands/add_text_index.py,sha256=cvBhX5rooRAXsn1Oput6b0B10w-MGMfS4ZPAhDfm7OQ,3669
32
+ qlever/commands/cache_stats.py,sha256=zGPLSWDNn7dwAAt2o-2ExqHmw1FeN8i6nEQbaaqF830,4156
33
+ qlever/commands/clear_cache.py,sha256=n52ohE1EE4M_B4kId_v8tbAlW-BGwG1K-ZYQ9QgxIJU,2974
34
+ qlever/commands/example_queries.py,sha256=8a7ViBkWP32UqC9-0vhmjo4mc6ZMfjnPlwzVthiHnPk,22792
35
+ qlever/commands/extract_queries.py,sha256=TZBmZLz_NknU1LKbl9nPmxdb82lsPeDhTWjIo81llvA,3942
36
+ qlever/commands/get_data.py,sha256=nHOHMjv0tSLWJDOR0ba_LK-Bk-mcGnphb8hbqcVYFhE,1411
37
+ qlever/commands/index.py,sha256=__vDlHnSkKNVqBAPZv2dzC5FYSI4QivOvjDHubFU35Q,12778
38
+ qlever/commands/index_stats.py,sha256=9EBo1Oq5PGjajrvWJNafJ-Wg_d90DaO5AGq9a5plSRM,11720
39
+ qlever/commands/log.py,sha256=vLqkgtx1udnQqoUBMWB5G9rwr-l7UKrDpyFYSMuoXWw,1987
40
+ qlever/commands/query.py,sha256=vu6vTeTqtKhuKbv_wzloHvbJFj_2GTHPIfDpQfrc8FE,3603
41
+ qlever/commands/settings.py,sha256=lyI_mdRMp3zv3RQ-tU2g2ZivfMD0r0R6ODf0VH9aVBk,3742
42
+ qlever/commands/setup_config.py,sha256=wEy1LAunpOnqrUCbazMpt1u9HJCKgXJEMxF3zjh0jb0,3344
43
+ qlever/commands/start.py,sha256=gtYKB1sgc5SwY0DA3IMnowXMqXccHA2cOYZ71dgey5k,11589
44
+ qlever/commands/status.py,sha256=TtnBqcdkF3zTDKft07zpVcIX7kFu7d_nOy9b6Ohh9vQ,1650
45
+ qlever/commands/stop.py,sha256=z25gWfLA9qIJ7F3zWZa0p0oVnt61kHcsB1evjgXhKX4,4557
46
+ qlever/commands/system_info.py,sha256=Y3DtUJAlnh6uSvIVoToE10G7SStu-L5NbalIXvBB6D0,4614
47
+ qlever/commands/ui.py,sha256=Ppo6YXA8JXNDPvC5D5duKGMPyhRvXfc1CaoSwjL-jBg,3644
48
+ qlever/commands/warmup.py,sha256=kJHzS7HJo8pD2CphJuaXDj_CYP02YDo2DVM-pun3A80,1029
49
+ qlever-0.5.17.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
50
+ qlever-0.5.17.dist-info/METADATA,sha256=lQ-9nEtPrTwq2umXW5yylTGjB_zDHpvnF8yaP0dlyXo,4583
51
+ qlever-0.5.17.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
52
+ qlever-0.5.17.dist-info/entry_points.txt,sha256=U_gbYYi0wwdsn884eb0XoOXfvhACOsxhlO330dZ9bi0,87
53
+ qlever-0.5.17.dist-info/top_level.txt,sha256=kd3zsYqiFd0--Czh5XTVkfEq6XR-XgRFW35X0v0GT-c,7
54
+ qlever-0.5.17.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,52 +0,0 @@
1
- qlever/__init__.py,sha256=7VKA8tp5iHZQyTXhDOcxUbloZ7WyxDnkruq0iJOzQcE,1403
2
- qlever/command.py,sha256=yOr0Uc8D8-AM7EjwDsVzbc3KNYjPH-FVOZhIHkqO588,2749
3
- qlever/config.py,sha256=qYPy-MQ7BwGrvKSazQWhs0lnlOFqm-d47mpZhc3fptc,10254
4
- qlever/containerize.py,sha256=bnHmjKIFEe-NcuAMRNnXAFjRVLcLnk9f5JspCCyhgt8,5210
5
- qlever/log.py,sha256=2O_RvFymnu_dB10ErBTAOsI8bgjORfdD0tE3USH-siM,1315
6
- qlever/qlever_main.py,sha256=tA_xqOs_FjvqlDIvKTprwuysfTwzsUjE7at26gRhCVA,2336
7
- qlever/qlever_old.py,sha256=X-JxmepFKYeFgSLLp0TRDNqXSxDwIbc8_0Xstiems8c,62026
8
- qlever/qleverfile.py,sha256=lygAjI5_wV_e-JoIGIqVTdd4yyvApzZiSlqSsmdlJpU,14529
9
- qlever/util.py,sha256=qLxBRyHPT2VTj0xcOCFcP6HV-Lm-g-64QpvOc4V0_a8,8029
10
- qlever/Qleverfiles/Qleverfile.dblp,sha256=nbkjBb6ZlmRgCsVcsx8U0EwI8csf8G03Rn2E10uCxVk,1269
11
- qlever/Qleverfiles/Qleverfile.dblp-plus,sha256=TJHxp8I1P6JKJjbuAllEpB32-huuY1gH0FlenqPVJ5g,1334
12
- qlever/Qleverfiles/Qleverfile.dbpedia,sha256=aaNZZayE-zVePGSwPzXemkX__Ns8-kP_E7DNNKZPnqg,1160
13
- qlever/Qleverfiles/Qleverfile.default,sha256=Kj-J1Kkv8PWN7wuMdZU6DUUlEuBIcSNysJCE-R63we8,2407
14
- qlever/Qleverfiles/Qleverfile.dnb,sha256=43w_CVi00yf7FHdDvBtHHQR3yU1d-JCNnD_uxYZJOvk,1803
15
- qlever/Qleverfiles/Qleverfile.fbeasy,sha256=9dwCMltT0BIMN4LRmaZFp1a7aV0kh0nJ9XLiQb_NJNo,940
16
- qlever/Qleverfiles/Qleverfile.freebase,sha256=eFMOxeyuWVbb06Gv2-VFkuKE5tTyckddTDHdw5wbZN8,1028
17
- qlever/Qleverfiles/Qleverfile.imdb,sha256=1xUBFimgnEHKP_o6tlqwJvIVpEE4Zx6UK_JnnQsG7Ew,1638
18
- qlever/Qleverfiles/Qleverfile.ohm-planet,sha256=yG6NgW6x6sGTzmCi1wEAkQ-i9goTj2u3PQxvCUwjExs,2122
19
- qlever/Qleverfiles/Qleverfile.olympics,sha256=5w9BOFwEBhdSzPz-0LRxwhv-7Gj6xbF539HOXr3cqD0,1088
20
- qlever/Qleverfiles/Qleverfile.orkg,sha256=Uizz-RhlSeExgfckWztewa4l_v3zMN8IR7NaGYKrqt4,937
21
- qlever/Qleverfiles/Qleverfile.osm-country,sha256=Pb9o5H3b7wVlVRgdiPHWCvrnkIRS1YUhxOazbUmoKZE,1897
22
- qlever/Qleverfiles/Qleverfile.osm-planet,sha256=555aaMOIzAILvzwpCjucd_GE7TlYxmT2Qh8hME68stU,1418
23
- qlever/Qleverfiles/Qleverfile.pubchem,sha256=YuDzWQmukSvL1opu7cf1KX9407_P21lmecYZ9cdbuvA,5611
24
- qlever/Qleverfiles/Qleverfile.scientists,sha256=9eZ2c6P9a3E3VHa3RR7LdOQbF4k3oyyrn56Z3u4LZYs,1164
25
- qlever/Qleverfiles/Qleverfile.uniprot,sha256=9kAKseomdUnIt7EAZge39g1MTuaLVaSW9JYLHzIMolM,2338
26
- qlever/Qleverfiles/Qleverfile.vvz,sha256=cLzm85erKoFCDllH5eFcSi35MdR6Tahj1MgtvGRxanM,922
27
- qlever/Qleverfiles/Qleverfile.wikidata,sha256=zVUXF75XJyK1h-J-7EjFemzmkSyoPtng1mNY3U7S78M,2061
28
- qlever/Qleverfiles/Qleverfile.wikipathways,sha256=UFEVLrtOBiSQfibBN9xc2wDXrnWcnx5f8PY9khcE6bc,1983
29
- qlever/Qleverfiles/Qleverfile.yago-4,sha256=hAS_2ZmC1zxNsKXip7t1F_iqu3CC-6O7v6HZhuFbnWY,1819
30
- qlever/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
- qlever/commands/add_text_index.py,sha256=dkqYtwgOhgnXiei_eyhBWYCtdAiQUEmjWoa3JMlMb4c,3641
32
- qlever/commands/cache_stats.py,sha256=6JjueQstAqc8dNfgY8TP2EitFMxdUvCwrcyd7KUEb2o,4157
33
- qlever/commands/clear_cache.py,sha256=AnE1MOoj1ZexxrRT8FGeBLlv8rtQIVV4DP8VBn5-X-s,2843
34
- qlever/commands/example_queries.py,sha256=rtMOQw7cJe0Aia_1O7UyKcxHbz7ln9BSZYWUQI9OFA8,16389
35
- qlever/commands/get_data.py,sha256=f9kjZI3TKad6JHSuXWNkeoajmW8h0Sx8ShvjauDCtNo,1412
36
- qlever/commands/index.py,sha256=y0HlFSTbRQSnXRz0fn3Mar9FqfnOtC2U1nu74N5IwCA,10842
37
- qlever/commands/index_stats.py,sha256=_BiUNBhmbYd9RPxrlm4HF0oENO6JmqnRiAkwkyOdN4U,11722
38
- qlever/commands/log.py,sha256=8Krt3MsTUDapYqVw1zUu5X15SF8mV97Uj0qKOWK8jXk,1861
39
- qlever/commands/query.py,sha256=_IDH-M8gKL_f1i5wzu0X452pZSUD0_qXl6bPXC85wX0,2750
40
- qlever/commands/setup_config.py,sha256=p0-wJcalzEOrSkIiaicQjOkp_WVNEeLsd0A_WZrlGfs,3345
41
- qlever/commands/start.py,sha256=2rOtk3NmhEs28D5csL_a1BdjSWU9VkcH6AqYT0vdww0,9285
42
- qlever/commands/status.py,sha256=5S6EdapZEwFKV9cQZtNYcZhMbAXAY-FP6ggjIhfX8ek,1631
43
- qlever/commands/stop.py,sha256=TZs4bxKHvujlZAU8BZmFjA5eXSZNAa6EeNzvPpEZsuI,4139
44
- qlever/commands/system_info.py,sha256=SShsnEV7QROgdbABeJ6Wk4U_CNjqlYO1J5HrpNCVNMs,4615
45
- qlever/commands/ui.py,sha256=rZxIYHZr-PqgQKfvVwl8woDnTGR-sFc-f6cPjcORaOk,3611
46
- qlever/commands/warmup.py,sha256=WOZSxeV8U_F6pEEnAb6YybXLQMxZFTRJXs4BPHUhsmc,1030
47
- qlever-0.5.12.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
48
- qlever-0.5.12.dist-info/METADATA,sha256=mm1muAfcKHTS4pN-xS3D0P4P57Z450Acifk2BckhAgc,4583
49
- qlever-0.5.12.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
50
- qlever-0.5.12.dist-info/entry_points.txt,sha256=U_gbYYi0wwdsn884eb0XoOXfvhACOsxhlO330dZ9bi0,87
51
- qlever-0.5.12.dist-info/top_level.txt,sha256=kd3zsYqiFd0--Czh5XTVkfEq6XR-XgRFW35X0v0GT-c,7
52
- qlever-0.5.12.dist-info/RECORD,,