11from __future__ import annotations
22
33import logging
4+ import subprocess
45from pathlib import Path
56from typing import Callable , Dict , List , Optional , Tuple , Union
67
7- import procrunner
8-
98from murfey .util import Processor
109from 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