MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / infoCB

Method infoCB

pager_lib/smb/base.py:961–986  ·  view source on GitHub ↗
(info_message, **kwargs)

Source from the content-addressed store, hash-verified

959 errback(OperationFailure('Failed to retrieve %s on %s: Unable to open file' % ( path, service_name ), messages_history))
960
961 def infoCB(info_message, **kwargs):
962 self._pushToArray(messages_history, info_message)
963 if info_message.status == 0:
964 file_len = struct.unpack('<Q', info_message.payload.data[8:16])[0]
965 if max_length == 0 or starting_offset > file_len:
966 if self.pbar:
967 self.pbar.close()
968 self.pbar = None
969 closeFid(info_message.tid, kwargs['fid'])
970 callback(( file_obj, kwargs['file_attributes'], 0 )) # Note that this is a tuple of 3-elements
971 else:
972 remaining_len = max_length
973 if remaining_len < 0:
974 remaining_len = file_len
975 if starting_offset + remaining_len > file_len:
976 remaining_len = file_len - starting_offset
977 if show_progress:
978 tqdm_kwargs.setdefault("total", remaining_len)
979 tqdm_kwargs.setdefault("unit", "B")
980 tqdm_kwargs.setdefault("unit_scale", True)
981 tqdm_kwargs.setdefault("unit_divisor", 1024)
982 tqdm_kwargs.setdefault("desc", f"Downloading {path}")
983 self.pbar = tqdm(**tqdm_kwargs)
984 sendRead(kwargs['tid'], kwargs['fid'], starting_offset, remaining_len, 0, kwargs['file_attributes'])
985 else:
986 errback(OperationFailure('Failed to retrieve %s on %s: Unable to retrieve information on file' % ( path, service_name ), messages_history))
987
988 def sendRead(tid, fid, offset, remaining_len, read_len, file_attributes):
989 read_count = min(self.max_read_size, remaining_len)

Callers

nothing calls this directly

Calls 5

_pushToArrayMethod · 0.95
tqdmClass · 0.90
OperationFailureClass · 0.85
callbackFunction · 0.50
closeMethod · 0.45

Tested by

no test coverage detected