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

Method retrieveFileFromOffset

pager_lib/smb/SMBProtocol.py:260–282  ·  view source on GitHub ↗

Retrieve the contents of the file at *path* on the *service_name* and write these contents to the provided *file_obj*. The meaning of the *timeout* parameter will be different from other file operation methods. As the downloaded file usually exceeeds the maximum size of eac

(self, service_name, path, file_obj, offset = 0, max_length = -1, timeout = 30)

Source from the content-addressed store, hash-verified

258 return self.retrieveFileFromOffset(service_name, path, file_obj, 0, -1, timeout)
259
260 def retrieveFileFromOffset(self, service_name, path, file_obj, offset = 0, max_length = -1, timeout = 30):
261 """
262 Retrieve the contents of the file at *path* on the *service_name* and write these contents to the provided *file_obj*.
263
264 The meaning of the *timeout* parameter will be different from other file operation methods. As the downloaded file usually exceeeds the maximum size
265 of each SMB/CIFS data message, it will be packetized into a series of request messages (each message will request about about 60kBytes).
266 The *timeout* parameter is an integer/float value that specifies the timeout interval for these individual SMB/CIFS message to be transmitted and downloaded from the remote SMB/CIFS server.
267
268 :param string/unicode service_name: the name of the shared folder for the *path*
269 :param string/unicode path: Path of the file on the remote server. If the file cannot be opened for reading, an :doc:`OperationFailure<smb_exceptions>` will be called in the returned *Deferred* errback.
270 :param file_obj: A file-like object that has a *write* method. Data will be written continuously to *file_obj* until EOF is received from the remote service. In Python3, this file-like object must have a *write* method which accepts a bytes parameter.
271 :param integer/long offset: the offset in the remote *path* where the first byte will be read and written to *file_obj*. Must be either zero or a positive integer/long value.
272 :param integer/long max_length: maximum number of bytes to read from the remote *path* and write to the *file_obj*. Specify a negative value to read from *offset* to the EOF.
273 If zero, the *Deferred* callback is invoked immediately after the file is opened successfully for reading.
274 :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a 3-element tuple of ( *file_obj*, file attributes of the file on server, number of bytes written to *file_obj* ).
275 The file attributes is an integer value made up from a bitwise-OR of *SMB_FILE_ATTRIBUTE_xxx* bits (see smb_constants.py)
276 """
277 if not self.instance:
278 raise NotConnectedError('Not connected to server')
279
280 d = defer.Deferred()
281 self.instance._retrieveFileFromOffset(service_name, path, file_obj, d.callback, d.errback, offset, max_length, timeout = timeout)
282 return d
283
284 def storeFile(self, service_name, path, file_obj, timeout = 30):
285 """

Callers 1

retrieveFileMethod · 0.95

Calls 1

NotConnectedErrorClass · 0.70

Tested by

no test coverage detected