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

Method _deleteFiles_SMB1

pager_lib/smb/base.py:2645–2706  ·  view source on GitHub ↗
(self, service_name, path_file_pattern, delete_matching_folders, callback, errback, timeout = 30)

Source from the content-addressed store, hash-verified

2643 sendOpen(self.connected_trees[service_name])
2644
2645 def _deleteFiles_SMB1(self, service_name, path_file_pattern, delete_matching_folders, callback, errback, timeout = 30):
2646 if not self.has_authenticated:
2647 raise NotReadyError('SMB connection not authenticated')
2648
2649 expiry_time = time.time() + timeout
2650 pattern = None
2651 path = path_file_pattern.replace('/', '\\')
2652 if path.startswith('\\'):
2653 path = path[1:]
2654 if path.endswith('\\'):
2655 path = path[:-1]
2656 else:
2657 path_components = path.split('\\')
2658 if path_components[-1].find('*') > -1 or path_components[-1].find('?') > -1:
2659 path = '\\'.join(path_components[:-1])
2660 pattern = path_components[-1]
2661 messages_history, files_queue = [ ], [ ]
2662
2663 if pattern is None:
2664 path_components = path.split('\\')
2665 if len(path_components) > 1:
2666 files_queue.append(( '\\'.join(path_components[:-1]), path_components[-1] ))
2667 else:
2668 files_queue.append(( '', path ))
2669
2670 def deleteCB(path):
2671 if files_queue:
2672 p, filename = files_queue.pop(0)
2673 if filename:
2674 if p:
2675 filename = p + '\\' + filename
2676 self._deleteFiles_SMB1__del(service_name, self.connected_trees[service_name], filename, deleteCB, errback, timeout)
2677 else:
2678 self._deleteDirectory_SMB1(service_name, p, deleteCB, errback, timeout = 30)
2679 else:
2680 callback(path_file_pattern)
2681
2682 def listCB(files_list):
2683 files_queue.extend(files_list)
2684 deleteCB(None)
2685
2686 if service_name not in self.connected_trees:
2687 def connectCB(connect_message, **kwargs):
2688 self._pushToArray(messages_history, connect_message)
2689 if not connect_message.status.hasError:
2690 self.connected_trees[service_name] = connect_message.tid
2691 if files_queue:
2692 deleteCB(None)
2693 else:
2694 self._deleteFiles_SMB1__list(service_name, path, pattern, delete_matching_folders, listCB, errback, timeout)
2695 else:
2696 errback(OperationFailure('Failed to delete %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
2697
2698 m = SMBMessage(ComTreeConnectAndxRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ), SERVICE_ANY, ''))
2699 self._sendSMBMessage(m)
2700 self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name)
2701 self._pushToArray(messages_history, m)
2702 else:

Callers

nothing calls this directly

Calls 7

_pushToArrayMethod · 0.95
NotReadyErrorClass · 0.85
SMBMessageClass · 0.85
_PendingRequestClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected