@@ -121,59 +121,51 @@ def _single_rsync(
121121 if retry :
122122 self ._in .put (root / sub_struct / f for f in self ._failed_tmp )
123123
124- def _parse_rsync_stdout (self , stdout : bytes | str ):
124+ def _parse_rsync_stdout (self , line : str ):
125125 """
126126 Parse rsync stdout to collect information such as the paths of transferred
127127 files and the amount of data transferred.
128128
129129 :param stdout: stdout of rsync process
130130 :type stdout: bytes
131131 """
132- stringy_stdout = str (stdout ) if isinstance (stdout , bytes ) else stdout
133- if stringy_stdout :
134- if self ._transferring :
135- if stringy_stdout .startswith ("sent" ):
136- self ._transferring = False
137- byte_info = stringy_stdout .split ()
138- self .sent_bytes = int (
139- byte_info [byte_info .index ("sent" ) + 1 ].replace ("," , "" )
140- )
141- self .received_bytes = int (
142- byte_info [byte_info .index ("received" ) + 1 ].replace ("," , "" )
143- )
144- self .byte_rate = float (
145- byte_info [byte_info .index ("bytes/sec" ) - 1 ].replace ("," , "" )
146- )
147- elif len (stringy_stdout .split ()) == 1 :
148- if self ._root and self ._sub_structure :
149- self ._notify (
150- self ._finaldir / self ._sub_structure / stringy_stdout
151- )
152- self ._out .put (self ._root / self ._sub_structure / stringy_stdout )
153- else :
154- logger .warning (
155- f"root or substructure not set for transfer of { stringy_stdout } "
156- )
157- else :
158- if "total size" in stringy_stdout :
159- self .total_size = int (
160- stringy_stdout .replace ("total size" , "" ).split ()[1 ]
132+ if self ._transferring :
133+ if line .startswith ("sent" ):
134+ self ._transferring = False
135+ byte_info = line .split ()
136+ self .sent_bytes = int (
137+ byte_info [byte_info .index ("sent" ) + 1 ].replace ("," , "" )
138+ )
139+ self .received_bytes = int (
140+ byte_info [byte_info .index ("received" ) + 1 ].replace ("," , "" )
141+ )
142+ self .byte_rate = float (
143+ byte_info [byte_info .index ("bytes/sec" ) - 1 ].replace ("," , "" )
144+ )
145+ elif len (line .split ()) == 1 :
146+ if self ._root and self ._sub_structure :
147+ self ._notify (self ._finaldir / self ._sub_structure / line )
148+ self ._out .put (self ._root / self ._sub_structure / line )
149+ else :
150+ logger .warning (
151+ f"root or substructure not set for transfer of { line } "
161152 )
153+ else :
154+ if "total size" in line :
155+ self .total_size = int (line .replace ("total size" , "" ).split ()[1 ])
162156
163- def _parse_rsync_stderr (self , stderr : bytes | str ):
157+ def _parse_rsync_stderr (self , line : str ):
164158 """
165159 Parse rsync stderr to collect information on any files that failed to transfer.
166160
167161 :param stderr: stderr of rsync process
168162 :type stderr: bytes
169163 """
170- stringy_stderr = str (stderr ) if isinstance (stderr , bytes ) else stderr
171- if stringy_stderr :
172- if (
173- stringy_stderr .startswith ("rsync: link_stat" )
174- or stringy_stderr .startswith ("rsync: [sender] link_stat" )
175- ) and "failed" in stringy_stderr :
176- failed_msg = stringy_stderr .split ()
177- self ._failed_tmp .append (
178- failed_msg [failed_msg .index ("failed:" ) - 1 ].replace ('"' , "" )
179- )
164+ if (
165+ line .startswith ("rsync: link_stat" )
166+ or line .startswith ("rsync: [sender] link_stat" )
167+ ) and "failed" in line :
168+ failed_msg = line .split ()
169+ self ._failed_tmp .append (
170+ failed_msg [failed_msg .index ("failed:" ) - 1 ].replace ('"' , "" )
171+ )
0 commit comments