Skip to content

Commit ab06896

Browse files
committed
No more procrunner
1 parent 2c400ac commit ab06896

File tree

6 files changed

+32
-37
lines changed

6 files changed

+32
-37
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ cicd = [
4242
"pytest-cov", # Used by Azure Pipelines for PyTest coverage reports
4343
]
4444
client = [
45-
"procrunner",
4645
"textual==0.42.0",
4746
"websocket-client",
4847
"xmltodict",

src/murfey/cli/transfer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import annotations
22

33
import argparse
4+
import subprocess
45
from pathlib import Path
56
from urllib.parse import urlparse
67

7-
import procrunner
88
import requests
99
from rich.console import Console
1010
from rich.prompt import Confirm
@@ -78,6 +78,6 @@ def run():
7878
cmd.extend(list(Path(args.source or ".").glob("*")))
7979
cmd.append(f"{murfey_url.hostname}::{args.destination}")
8080

81-
result = procrunner.run(cmd)
81+
result = subprocess.run(cmd)
8282
if result.returncode:
8383
console.print(f"[red]rsync failed returning code {result.returncode}")

src/murfey/client/rsync.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
from typing import List, NamedTuple
1919
from urllib.parse import ParseResult
2020

21-
import procrunner
22-
2321
from murfey.client.tui.status_bar import StatusBar
2422
from murfey.util import Observer
2523

@@ -408,28 +406,29 @@ def parse_stderr(line: str):
408406
result: subprocess.CompletedProcess | None = None
409407
success = True
410408
if rsync_stdin:
411-
result = procrunner.run(
409+
result = subprocess.run(
412410
rsync_cmd,
413-
callback_stdout=parse_stdout,
414-
callback_stderr=parse_stderr,
415-
working_directory=str(self._basepath),
416-
stdin=rsync_stdin,
417-
print_stdout=False,
418-
print_stderr=False,
411+
cwd=str(self._basepath),
412+
capture_output=True,
413+
input=rsync_stdin,
419414
)
420-
success = result.returncode == 0 if result else False
415+
for stdout_line in result.stdout.decode("utf8", "replace").split("\n"):
416+
parse_stdout(stdout_line)
417+
for stderr_line in result.stderr.decode("utf8", "replace").split("\n"):
418+
parse_stderr(stderr_line)
419+
success = result.returncode == 0
421420

422421
if rsync_stdin_remove:
423422
rsync_cmd.insert(-2, "--remove-source-files")
424-
result = procrunner.run(
423+
result = subprocess.run(
425424
rsync_cmd,
426-
callback_stdout=parse_stdout,
427-
callback_stderr=parse_stderr,
428-
working_directory=str(self._basepath),
429-
stdin=rsync_stdin_remove,
430-
print_stdout=False,
431-
print_stderr=False,
425+
cwd=str(self._basepath),
426+
input=rsync_stdin_remove,
432427
)
428+
for stdout_line in result.stdout.decode("utf8", "replace").split("\n"):
429+
parse_stdout(stdout_line)
430+
for stderr_line in result.stderr.decode("utf8", "replace").split("\n"):
431+
parse_stderr(stderr_line)
433432

434433
if success:
435434
success = result.returncode == 0 if result else False

src/murfey/client/tui/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from __future__ import annotations
22

33
import logging
4+
import subprocess
45
from datetime import datetime
56
from functools import partial
67
from pathlib import Path
78
from queue import Queue
89
from typing import Awaitable, Callable, Dict, List, OrderedDict, TypeVar
910
from urllib.parse import urlparse
1011

11-
import procrunner
1212
import requests
1313
from textual.app import App
1414
from textual.reactive import reactive
@@ -203,7 +203,7 @@ def _start_rsyncer(
203203
if self._environment:
204204
self._environment.default_destinations[source] = destination
205205
if self._environment.gain_ref and visit_path:
206-
gain_rsync = procrunner.run(
206+
gain_rsync = subprocess.run(
207207
[
208208
"rsync",
209209
str(self._environment.gain_ref),

src/murfey/client/tui/screens.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# import contextlib
44
import logging
5+
import subprocess
56
from datetime import datetime
67
from functools import partial
78
from pathlib import Path
@@ -17,7 +18,6 @@
1718
TypeVar,
1819
)
1920

20-
import procrunner
2121
import requests
2222
from pydantic import BaseModel, ValidationError
2323
from rich.box import SQUARE
@@ -844,7 +844,7 @@ def on_button_pressed(self, event):
844844
if self.app._environment.demo:
845845
log.info(f"Would perform {' '.join(cmd)}")
846846
else:
847-
gain_rsync = procrunner.run(cmd)
847+
gain_rsync = subprocess.run(cmd)
848848
if gain_rsync.returncode:
849849
log.warning(
850850
f"Gain reference file {self._dir_tree._gain_reference} was not successfully transferred to {visit_path}/processing"

src/murfey/util/rsync.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from __future__ import annotations
22

33
import logging
4+
import subprocess
45
from pathlib import Path
56
from typing import Callable, Dict, List, Optional, Tuple, Union
67

7-
import procrunner
8-
98
from murfey.util import Processor
109
from murfey.util.file_monitor import Monitor
1110

@@ -32,7 +31,7 @@ def __init__(
3231
self.received_bytes = 0
3332
self.byte_rate: float = 0
3433
self.total_size = 0
35-
self.runner_return: List[procrunner.ReturnObject] = []
34+
self.runner_return: List[subprocess.CompletedProcess] = []
3635
self._root = root
3736
self._sub_structure: Optional[Path] = None
3837
self._notify = notify or (lambda f: None)
@@ -53,7 +52,7 @@ def _run_rsync(
5352
retry: bool = True,
5453
):
5554
"""
56-
Run rsync -v on a list of files using procrunner.
55+
Run rsync -v on a list of files using subprocess run.
5756
5857
:param root: root path of files for transferring; structure below the root is preserved
5958
:type root: pathlib.Path object
@@ -109,11 +108,11 @@ def _single_rsync(
109108
else:
110109
cmd.append(str(self._finaldir / sub_struct) + "/")
111110
self._transferring = True
112-
runner = procrunner.run(
113-
cmd,
114-
callback_stdout=self._parse_rsync_stdout,
115-
callback_stderr=self._parse_rsync_stderr,
116-
)
111+
112+
runner = subprocess.run(cmd, capture_output=True)
113+
self._parse_rsync_stdout(runner.stdout)
114+
self._parse_rsync_stderr(runner.stderr)
115+
117116
self.runner_return.append(runner)
118117
self.failed.extend(root / sub_struct / f for f in self._failed_tmp)
119118
if retry:
@@ -127,8 +126,7 @@ def _parse_rsync_stdout(self, stdout: bytes):
127126
:param stdout: stdout of rsync process
128127
:type stdout: bytes
129128
"""
130-
stringy_stdout = str(stdout)
131-
if stringy_stdout:
129+
for stringy_stdout in stdout.decode("utf8", "replace").split("\n"):
132130
if self._transferring:
133131
if stringy_stdout.startswith("sent"):
134132
self._transferring = False
@@ -165,8 +163,7 @@ def _parse_rsync_stderr(self, stderr: bytes):
165163
:param stderr: stderr of rsync process
166164
:type stderr: bytes
167165
"""
168-
stringy_stderr = str(stderr)
169-
if stringy_stderr:
166+
for stringy_stderr in stderr.decode("utf8", "replace").split("\n"):
170167
if (
171168
stringy_stderr.startswith("rsync: link_stat")
172169
and "failed" in stringy_stderr

0 commit comments

Comments
 (0)