foamlib 0.6.0__py3-none-any.whl → 0.6.1__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.
- foamlib/__init__.py +1 -1
- foamlib/_cases/_subprocess.py +60 -7
- foamlib/_cases/_sync.py +1 -1
- {foamlib-0.6.0.dist-info → foamlib-0.6.1.dist-info}/METADATA +1 -1
- {foamlib-0.6.0.dist-info → foamlib-0.6.1.dist-info}/RECORD +8 -8
- {foamlib-0.6.0.dist-info → foamlib-0.6.1.dist-info}/LICENSE.txt +0 -0
- {foamlib-0.6.0.dist-info → foamlib-0.6.1.dist-info}/WHEEL +0 -0
- {foamlib-0.6.0.dist-info → foamlib-0.6.1.dist-info}/top_level.txt +0 -0
foamlib/__init__.py
CHANGED
foamlib/_cases/_subprocess.py
CHANGED
@@ -9,9 +9,19 @@ if sys.version_info >= (3, 9):
|
|
9
9
|
else:
|
10
10
|
from typing import Mapping, Sequence
|
11
11
|
|
12
|
-
CalledProcessError = subprocess.CalledProcessError
|
13
12
|
CompletedProcess = subprocess.CompletedProcess
|
14
13
|
|
14
|
+
|
15
|
+
class CalledProcessError(subprocess.CalledProcessError):
|
16
|
+
def __str__(self) -> str:
|
17
|
+
if self.stderr:
|
18
|
+
if isinstance(self.stderr, bytes):
|
19
|
+
return super().__str__() + "\n" + self.stderr.decode()
|
20
|
+
elif isinstance(self.stderr, str):
|
21
|
+
return super().__str__() + "\n" + self.stderr
|
22
|
+
return super().__str__()
|
23
|
+
|
24
|
+
|
15
25
|
DEVNULL = subprocess.DEVNULL
|
16
26
|
PIPE = subprocess.PIPE
|
17
27
|
STDOUT = subprocess.STDOUT
|
@@ -29,14 +39,43 @@ def run_sync(
|
|
29
39
|
if not isinstance(cmd, str) and sys.version_info < (3, 8):
|
30
40
|
cmd = [str(arg) for arg in cmd]
|
31
41
|
|
32
|
-
|
42
|
+
proc = subprocess.Popen(
|
33
43
|
cmd,
|
34
44
|
cwd=cwd,
|
35
45
|
env=env,
|
36
46
|
stdout=stdout,
|
37
|
-
stderr=
|
47
|
+
stderr=PIPE,
|
38
48
|
shell=isinstance(cmd, str),
|
39
|
-
|
49
|
+
)
|
50
|
+
|
51
|
+
error = b""
|
52
|
+
|
53
|
+
if stderr == STDOUT:
|
54
|
+
stderr = stdout
|
55
|
+
if stderr not in (PIPE, DEVNULL):
|
56
|
+
assert not isinstance(stderr, int)
|
57
|
+
if stderr is None:
|
58
|
+
stderr = sys.stderr.buffer
|
59
|
+
|
60
|
+
assert proc.stderr is not None
|
61
|
+
for line in proc.stderr:
|
62
|
+
error += line
|
63
|
+
stderr.write(line)
|
64
|
+
|
65
|
+
output, _ = proc.communicate()
|
66
|
+
assert not _
|
67
|
+
assert proc.returncode is not None
|
68
|
+
|
69
|
+
if check and proc.returncode != 0:
|
70
|
+
raise CalledProcessError(
|
71
|
+
returncode=proc.returncode,
|
72
|
+
cmd=cmd,
|
73
|
+
output=output,
|
74
|
+
stderr=error,
|
75
|
+
)
|
76
|
+
|
77
|
+
return CompletedProcess(
|
78
|
+
cmd, returncode=proc.returncode, stdout=output, stderr=error
|
40
79
|
)
|
41
80
|
|
42
81
|
|
@@ -55,7 +94,7 @@ async def run_async(
|
|
55
94
|
cwd=cwd,
|
56
95
|
env=env,
|
57
96
|
stdout=stdout,
|
58
|
-
stderr=
|
97
|
+
stderr=PIPE,
|
59
98
|
)
|
60
99
|
|
61
100
|
else:
|
@@ -66,11 +105,25 @@ async def run_async(
|
|
66
105
|
cwd=cwd,
|
67
106
|
env=env,
|
68
107
|
stdout=stdout,
|
69
|
-
stderr=
|
108
|
+
stderr=PIPE,
|
70
109
|
)
|
71
110
|
|
72
|
-
|
111
|
+
error = b""
|
112
|
+
|
113
|
+
if stderr == STDOUT:
|
114
|
+
stderr = stdout
|
115
|
+
if stderr not in (PIPE, DEVNULL):
|
116
|
+
assert not isinstance(stderr, int)
|
117
|
+
if stderr is None:
|
118
|
+
stderr = sys.stderr.buffer
|
119
|
+
|
120
|
+
assert proc.stderr is not None
|
121
|
+
async for line in proc.stderr:
|
122
|
+
error += line
|
123
|
+
stderr.write(line)
|
73
124
|
|
125
|
+
output, _ = await proc.communicate()
|
126
|
+
assert not _
|
74
127
|
assert proc.returncode is not None
|
75
128
|
|
76
129
|
if check and proc.returncode != 0:
|
foamlib/_cases/_sync.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
foamlib/__init__.py,sha256=
|
1
|
+
foamlib/__init__.py,sha256=BVCe7vPVevu5BHTZMwbL8VQEQCStIT_j_p_4bGfVW1A,392
|
2
2
|
foamlib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
foamlib/_cases/__init__.py,sha256=C0mpRu7c-X-4uVMKmVrZhwIyhBNyvUoCv0o-BQ72RC0,236
|
4
4
|
foamlib/_cases/_async.py,sha256=8x8Mkql6XPzMjH4t-NszAEDx4gpjNPnQiWxFkHrcFJU,6436
|
5
5
|
foamlib/_cases/_base.py,sha256=1CUkkK4afBxDgP79dmho97WJdj-GLgYhnrCSf_52Eao,6604
|
6
6
|
foamlib/_cases/_run.py,sha256=0xu5V3qvWnXYJvOh0GV8DM1gOiNc65frWJF3mviHPOM,12307
|
7
|
-
foamlib/_cases/_subprocess.py,sha256=
|
8
|
-
foamlib/_cases/_sync.py,sha256=
|
7
|
+
foamlib/_cases/_subprocess.py,sha256=GTmHWy1LRD9ujpXJfSTXU2bf87GncpIA0VOR1rQW2fg,3633
|
8
|
+
foamlib/_cases/_sync.py,sha256=PzwciC4kFfenlG0XOtbBMxd9EuQBChwxZGA3RDlmWXM,4752
|
9
9
|
foamlib/_cases/_util.py,sha256=GNndpqw3Jg_S-Hxzl5vwRgD0czcTNb9NYHMhcfBoMBg,1493
|
10
10
|
foamlib/_files/__init__.py,sha256=-UqB9YTH6mrJfXCX00kPTAAY20XG64u1MGPw_1ewLVs,148
|
11
11
|
foamlib/_files/_base.py,sha256=zaFDjLE6jB7WtGWk8hfKusjLtlGu6CZV16AHJpRUibs,1929
|
@@ -14,8 +14,8 @@ foamlib/_files/_io.py,sha256=uSh5XlgukwJkQSLELa4mshRD2aTajNk5vr_ZsBImSeU,2423
|
|
14
14
|
foamlib/_files/_parsing.py,sha256=DzgJ53QnohRQyLXn2zOs52RIQ7bJ_fS_S2Z7rmRyVK4,9023
|
15
15
|
foamlib/_files/_serialization.py,sha256=pb8_cIVgRhGS_ZV2p3x8p5_lK1SS6xzQHscAYYuOgFY,3407
|
16
16
|
foamlib/_files/_util.py,sha256=UMzXmTFgvbp46w6k3oEZJoYC98pFgEK6LN5uLOwrlCg,397
|
17
|
-
foamlib-0.6.
|
18
|
-
foamlib-0.6.
|
19
|
-
foamlib-0.6.
|
20
|
-
foamlib-0.6.
|
21
|
-
foamlib-0.6.
|
17
|
+
foamlib-0.6.1.dist-info/LICENSE.txt,sha256=5Dte9TUnLZzPRs4NQzl-Jc2-Ljd-t_v0ZR5Ng5r0UsY,35131
|
18
|
+
foamlib-0.6.1.dist-info/METADATA,sha256=wCN0T5tNyAtSUx5k8ehwqjX05fJDV_vBbw4j-pTqNbI,6338
|
19
|
+
foamlib-0.6.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
20
|
+
foamlib-0.6.1.dist-info/top_level.txt,sha256=ZdVYtetXGwPwyfL-WhlhbTFQGAwKX5P_gXxtH9JYFPI,8
|
21
|
+
foamlib-0.6.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|