foamlib 0.6.0__tar.gz → 0.6.2__tar.gz
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-0.6.0 → foamlib-0.6.2}/PKG-INFO +1 -1
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/__init__.py +1 -1
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_cases/_run.py +6 -6
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_cases/_subprocess.py +60 -7
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_cases/_sync.py +4 -2
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib.egg-info/PKG-INFO +1 -1
- {foamlib-0.6.0 → foamlib-0.6.2}/LICENSE.txt +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/README.md +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_cases/__init__.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_cases/_async.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_cases/_base.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_cases/_util.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_files/__init__.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_files/_base.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_files/_files.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_files/_io.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_files/_parsing.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_files/_serialization.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/_files/_util.py +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib/py.typed +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib.egg-info/SOURCES.txt +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib.egg-info/dependency_links.txt +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib.egg-info/requires.txt +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/foamlib.egg-info/top_level.txt +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/pyproject.toml +0 -0
- {foamlib-0.6.0 → foamlib-0.6.2}/setup.cfg +0 -0
@@ -177,7 +177,7 @@ class FoamCaseRunBase(FoamCaseBase):
|
|
177
177
|
|
178
178
|
return script
|
179
179
|
|
180
|
-
def __run_script(self, *, parallel: Optional[bool]
|
180
|
+
def __run_script(self, *, parallel: Optional[bool]) -> Optional[Path]:
|
181
181
|
"""Return the path to the (All)run script, or None if no run script is found."""
|
182
182
|
run = self.path / "run"
|
183
183
|
run_parallel = self.path / "run-parallel"
|
@@ -263,7 +263,7 @@ class FoamCaseRunBase(FoamCaseBase):
|
|
263
263
|
|
264
264
|
return type(self)(dst)
|
265
265
|
|
266
|
-
def _clean_calls(self, *, check: bool
|
266
|
+
def _clean_calls(self, *, check: bool) -> Generator[Any, None, None]:
|
267
267
|
script_path = self.__clean_script()
|
268
268
|
|
269
269
|
if script_path is not None:
|
@@ -299,10 +299,10 @@ class FoamCaseRunBase(FoamCaseBase):
|
|
299
299
|
self,
|
300
300
|
cmd: Optional[Union[Sequence[Union[str, "os.PathLike[str]"]], str]] = None,
|
301
301
|
*,
|
302
|
-
parallel: Optional[bool]
|
303
|
-
cpus: Optional[int]
|
304
|
-
check: bool
|
305
|
-
log: bool
|
302
|
+
parallel: Optional[bool],
|
303
|
+
cpus: Optional[int],
|
304
|
+
check: bool,
|
305
|
+
log: bool,
|
306
306
|
) -> Generator[Any, None, None]:
|
307
307
|
if cmd is not None:
|
308
308
|
if parallel:
|
@@ -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:
|
@@ -67,7 +67,7 @@ class FoamCase(FoamCaseRunBase):
|
|
67
67
|
) -> None:
|
68
68
|
shutil.copytree(src, dest, symlinks=symlinks, ignore=ignore)
|
69
69
|
|
70
|
-
def __enter__(self) ->
|
70
|
+
def __enter__(self) -> Self:
|
71
71
|
return self
|
72
72
|
|
73
73
|
def __exit__(
|
@@ -105,7 +105,9 @@ class FoamCase(FoamCaseRunBase):
|
|
105
105
|
:param check: If True, raise a CalledProcessError if any command returns a non-zero exit code.
|
106
106
|
:param log: If True, log the command output to a file.
|
107
107
|
"""
|
108
|
-
for _ in self._run_calls(
|
108
|
+
for _ in self._run_calls(
|
109
|
+
cmd=cmd, parallel=parallel, cpus=cpus, check=check, log=log
|
110
|
+
):
|
109
111
|
pass
|
110
112
|
|
111
113
|
def block_mesh(self, *, check: bool = True) -> None:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|