Skip to content

Commit 45590a9

Browse files
committed
Replaced remaining instances of 'procrunner' with 'subprocess'
1 parent a67ae92 commit 45590a9

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
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
@@ -76,6 +76,6 @@ def run():
7676
cmd.extend(list(Path(args.source or ".").glob("*")))
7777
cmd.append(f"{murfey_url.hostname}::{args.destination}")
7878

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

src/murfey/instrument_server/api.py

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

33
import secrets
4+
import subprocess
45
import time
56
from datetime import datetime
67
from functools import partial
@@ -9,7 +10,6 @@
910
from typing import Annotated, Dict, List, Optional, Union
1011
from urllib.parse import urlparse
1112

12-
import procrunner
1313
import requests
1414
from fastapi import APIRouter, Depends, HTTPException, status
1515
from fastapi.security import OAuth2PasswordBearer
@@ -283,7 +283,7 @@ def upload_gain_reference(session_id: MurfeySessionID, gain_reference: GainRefer
283283
str(gain_reference.gain_path),
284284
f"{urlparse(_get_murfey_url(), allow_fragments=False).hostname}::{gain_reference.visit_path}/{gain_reference.gain_destination_dir}/{secure_filename(gain_reference.gain_path.name)}",
285285
]
286-
gain_rsync = procrunner.run(cmd)
286+
gain_rsync = subprocess.run(cmd)
287287
if gain_rsync.returncode:
288288
safe_gain_path = (
289289
str(gain_reference.gain_path).replace("\r\n", "").replace("\n", "")

src/murfey/util/rsync.py

Lines changed: 13 additions & 11 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.
5756
5857
:param root: root path of files for transferring; structure below the root is preserved
5958
:type root: pathlib.Path object
@@ -109,25 +108,28 @@ def _single_rsync(
109108
else:
110109
cmd.append(str(self._finaldir / sub_struct) + "/")
111110
self._transferring = True
112-
runner = procrunner.run(
111+
runner = subprocess.run(
113112
cmd,
114-
callback_stdout=self._parse_rsync_stdout,
115-
callback_stderr=self._parse_rsync_stderr,
113+
capture_output=True,
116114
)
115+
for line in runner.stdout.decode("utf-8", "replace").split("\n"):
116+
self._parse_rsync_stdout(line)
117+
for line in runner.stderr.decode("utf-8", "replace").split("\n"):
118+
self._parse_rsync_stderr(line)
117119
self.runner_return.append(runner)
118120
self.failed.extend(root / sub_struct / f for f in self._failed_tmp)
119121
if retry:
120122
self._in.put(root / sub_struct / f for f in self._failed_tmp)
121123

122-
def _parse_rsync_stdout(self, stdout: bytes):
124+
def _parse_rsync_stdout(self, stdout: bytes | str):
123125
"""
124126
Parse rsync stdout to collect information such as the paths of transferred
125127
files and the amount of data transferred.
126128
127129
:param stdout: stdout of rsync process
128130
:type stdout: bytes
129131
"""
130-
stringy_stdout = str(stdout)
132+
stringy_stdout = str(stdout) if isinstance(stdout, bytes) else stdout
131133
if stringy_stdout:
132134
if self._transferring:
133135
if stringy_stdout.startswith("sent"):
@@ -158,14 +160,14 @@ def _parse_rsync_stdout(self, stdout: bytes):
158160
stringy_stdout.replace("total size", "").split()[1]
159161
)
160162

161-
def _parse_rsync_stderr(self, stderr: bytes):
163+
def _parse_rsync_stderr(self, stderr: bytes | str):
162164
"""
163165
Parse rsync stderr to collect information on any files that failed to transfer.
164166
165167
:param stderr: stderr of rsync process
166168
:type stderr: bytes
167169
"""
168-
stringy_stderr = str(stderr)
170+
stringy_stderr = str(stderr) if isinstance(stderr, bytes) else stderr
169171
if stringy_stderr:
170172
if (
171173
stringy_stderr.startswith("rsync: link_stat")

0 commit comments

Comments
 (0)