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

Method resetFileAttributes

pager_lib/smb/SMBConnection.py:444–477  ·  view source on GitHub ↗

Reset file attributes of one or more regular files or folders. It supports the use of wildcards in file names, allowing for unlocking of multiple files/folders in a single request. This function is very helpful when deleting files/folders that are read-only. By defau

(self, service_name, path_file_pattern, file_attributes = ATTR_NORMAL, timeout = 30)

Source from the content-addressed store, hash-verified

442 self.is_busy = False
443
444 def resetFileAttributes(self, service_name, path_file_pattern, file_attributes = ATTR_NORMAL, timeout = 30):
445 """
446 Reset file attributes of one or more regular files or folders.
447 It supports the use of wildcards in file names, allowing for unlocking of multiple files/folders in a single request.
448 This function is very helpful when deleting files/folders that are read-only.
449 By default, it sets the ATTR_NORMAL flag, therefore clearing all other flags.
450 (See https://msdn.microsoft.com/en-us/library/cc232110.aspx for further information)
451
452 Note: this function is currently only implemented for SMB2!
453
454 :param string/unicode service_name: Contains the name of the shared folder.
455 :param string/unicode path_file_pattern: The pathname of the file(s) to be deleted, relative to the service_name.
456 Wildcards may be used in the filename component of the path.
457 If your path/filename contains non-English characters, you must pass in an unicode string.
458 :param int file_attributes: The desired file attributes to set. Defaults to `ATTR_NORMAL`.
459 :return: None
460 """
461 if not self.sock:
462 raise NotConnectedError('Not connected to server')
463
464 def cb(r):
465 self.is_busy = False
466
467 def eb(failure):
468 self.is_busy = False
469 raise failure
470
471 self.is_busy = True
472 try:
473 self._resetFileAttributes(service_name, path_file_pattern, cb, eb, file_attributes, timeout)
474 while self.is_busy:
475 self._pollForNetBIOSPacket(timeout)
476 finally:
477 self.is_busy = False
478
479 def createDirectory(self, service_name, path, timeout = 30):
480 """

Callers

nothing calls this directly

Calls 2

_pollForNetBIOSPacketMethod · 0.95
NotConnectedErrorClass · 0.70

Tested by

no test coverage detected