Skip to content

Commit 5bdc4b5

Browse files
committed
Show stdout/stderr if fails call
Signed-off-by: Bernát Gábor <[email protected]>
1 parent d672220 commit 5bdc4b5

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.3 (2021-12-03)
4+
5+
- Show stdout/stderr details if a command fails
6+
37
## 0.2 (2021-12-29)
48

59
- Drop 3.6 support and bump linters

src/devpi_process/__init__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77
import sysconfig
88
from contextlib import closing
99
from pathlib import Path
10-
from subprocess import PIPE, Popen, check_call
10+
from subprocess import PIPE, Popen, run
1111
from threading import Thread
1212
from types import TracebackType
1313
from typing import IO, Iterator, Sequence, cast
1414

1515
from .version import __version__
1616

1717

18+
def _check_call(cmd: list[str]) -> None:
19+
run(cmd, check=True, stdout=PIPE, stderr=PIPE)
20+
21+
1822
class Index:
1923
def __init__(self, base_url: str, name: str, user: str, client_cmd_base: list[str]) -> None:
2024
self._client_cmd_base = client_cmd_base
@@ -27,11 +31,11 @@ def url(self) -> str:
2731
return f"{self._server_url}/{self.name}/+simple/"
2832

2933
def use(self) -> None:
30-
check_call(self._client_cmd_base + ["use", f"{self.user}/{self.name}"], stdout=PIPE, stderr=PIPE)
34+
_check_call(self._client_cmd_base + ["use", f"{self.user}/{self.name}"])
3135

3236
def upload(self, *files: Path) -> None:
3337
cmd = self._client_cmd_base + ["upload", "--index", self.name] + [str(i) for i in files]
34-
check_call(cmd)
38+
_check_call(cmd)
3539

3640
def __repr__(self) -> str:
3741
return f"{self.__class__.__name__}(url={self.url})"
@@ -81,7 +85,7 @@ def _create_and_start_server(self) -> None:
8185
cmd.extend(("--role", "standalone", "--root-passwd", self._passwd))
8286
if self._with_root_pypi is False:
8387
cmd.append("--no-root-pypi")
84-
check_call(cmd, stdout=PIPE, stderr=PIPE)
88+
_check_call(cmd)
8589
# 2. start the server
8690
cmd = [self._server, "--serverdir", server_at, "--port", str(self.port)]
8791
cmd.extend(self._start_args)
@@ -112,14 +116,14 @@ def _setup_client(self) -> None:
112116
"""create a user on the server and authenticate it"""
113117
self._client_dir.mkdir(exist_ok=True)
114118
base = ["--clientdir", str(self._client_dir)]
115-
check_call([self._client, "use"] + base + [self.url], stdout=PIPE, stderr=PIPE)
116-
check_call([self._client, "login"] + base + [self.user, "--password", self._passwd], stdout=PIPE, stderr=PIPE)
119+
_check_call([self._client, "use"] + base + [self.url])
120+
_check_call([self._client, "login"] + base + [self.user, "--password", self._passwd])
117121

118122
def create_index(self, name: str, *args: str) -> Index:
119123
if name in self._indexes: # pragma: no cover
120124
raise ValueError(f"index {name} already exists")
121125
base = [self._client, "--clientdir", str(self._client_dir)]
122-
check_call(base + ["index", "-c", name, *args], stdout=PIPE, stderr=PIPE)
126+
_check_call(base + ["index", "-c", name, *args])
123127
index = Index(f"{self.url}/{self.user}", name, self.user, base)
124128
self._indexes[name] = index
125129
return index

whitelist.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
addfile
2-
cmd
32
devpi
4-
dirname
5-
exc
63
exe
74
getsockname
85
inet
96
mktemp
10-
popen
117
readline
128
sdist
139
sysconfig
14-
tmp
1510
tmpdir
16-
util
17-
writestr

0 commit comments

Comments
 (0)