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

Method _createDirectory_SMB1

pager_lib/smb/base.py:2767–2802  ·  view source on GitHub ↗
(self, service_name, path, callback, errback, timeout = 30)

Source from the content-addressed store, hash-verified

2765 raise NotReadyError('resetFileAttributes is not yet implemented for SMB1')
2766
2767 def _createDirectory_SMB1(self, service_name, path, callback, errback, timeout = 30):
2768 if not self.has_authenticated:
2769 raise NotReadyError('SMB connection not authenticated')
2770
2771 path = path.replace('/', '\\')
2772 messages_history = [ ]
2773
2774 def sendCreate(tid):
2775 m = SMBMessage(ComCreateDirectoryRequest(path))
2776 m.tid = tid
2777 self._sendSMBMessage(m)
2778 self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, createCB, errback)
2779 self._pushToArray(messages_history, m)
2780
2781 def createCB(create_message, **kwargs):
2782 self._pushToArray(messages_history, create_message)
2783 if not create_message.status.hasError:
2784 callback(path)
2785 else:
2786 errback(OperationFailure('Failed to create directory %s on %s: Create failed' % ( path, service_name ), messages_history))
2787
2788 if service_name not in self.connected_trees:
2789 def connectCB(connect_message, **kwargs):
2790 self._pushToArray(messages_history, connect_message)
2791 if not connect_message.status.hasError:
2792 self.connected_trees[service_name] = connect_message.tid
2793 sendCreate(connect_message.tid)
2794 else:
2795 errback(OperationFailure('Failed to create directory %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
2796
2797 m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
2798 self._sendSMBMessage(m)
2799 self.pending_requests[m.mid] = _PendingRequest(m.mid, int(time.time()) + timeout, connectCB, errback, path = service_name)
2800 self._pushToArray(messages_history, m)
2801 else:
2802 sendCreate(self.connected_trees[service_name])
2803
2804 def _deleteDirectory_SMB1(self, service_name, path, callback, errback, timeout = 30):
2805 if not self.has_authenticated:

Callers

nothing calls this directly

Calls 5

_pushToArrayMethod · 0.95
NotReadyErrorClass · 0.85
SMBMessageClass · 0.85
_PendingRequestClass · 0.85

Tested by

no test coverage detected