(self, service_name, path_file_pattern, delete_matching_folders, callback, errback, timeout = 30)
| 1162 | |
| 1163 | |
| 1164 | def _deleteFiles_SMB2(self, service_name, path_file_pattern, delete_matching_folders, callback, errback, timeout = 30): |
| 1165 | if not self.has_authenticated: |
| 1166 | raise NotReadyError('SMB connection not authenticated') |
| 1167 | |
| 1168 | expiry_time = time.time() + timeout |
| 1169 | pattern = None |
| 1170 | path = path_file_pattern.replace('/', '\\') |
| 1171 | if path.startswith('\\'): |
| 1172 | path = path[1:] |
| 1173 | if path.endswith('\\'): |
| 1174 | path = path[:-1] |
| 1175 | else: |
| 1176 | path_components = path.split('\\') |
| 1177 | if path_components[-1].find('*') > -1 or path_components[-1].find('?') > -1: |
| 1178 | path = '\\'.join(path_components[:-1]) |
| 1179 | pattern = path_components[-1] |
| 1180 | messages_history, files_queue = [ ], [ ] |
| 1181 | |
| 1182 | if pattern is None: |
| 1183 | path_components = path.split('\\') |
| 1184 | if len(path_components) > 1: |
| 1185 | files_queue.append(( '\\'.join(path_components[:-1]), path_components[-1] )) |
| 1186 | else: |
| 1187 | files_queue.append(( '', path )) |
| 1188 | |
| 1189 | def deleteCB(path): |
| 1190 | if files_queue: |
| 1191 | p, filename = files_queue.pop(0) |
| 1192 | if filename: |
| 1193 | if p: |
| 1194 | filename = p + '\\' + filename |
| 1195 | self._deleteFiles_SMB2__del(service_name, self.connected_trees[service_name], filename, deleteCB, errback, timeout) |
| 1196 | else: |
| 1197 | self._deleteDirectory_SMB2(service_name, p, deleteCB, errback, timeout) |
| 1198 | else: |
| 1199 | callback(path_file_pattern) |
| 1200 | |
| 1201 | def listCB(files_list): |
| 1202 | files_queue.extend(files_list) |
| 1203 | deleteCB(None) |
| 1204 | |
| 1205 | if service_name not in self.connected_trees: |
| 1206 | def connectCB(connect_message, **kwargs): |
| 1207 | self._pushToArray(messages_history, connect_message) |
| 1208 | if connect_message.status == 0: |
| 1209 | self.connected_trees[service_name] = connect_message.tid |
| 1210 | if files_queue: |
| 1211 | deleteCB(None) |
| 1212 | else: |
| 1213 | self._deleteFiles_SMB2__list(service_name, path, pattern, delete_matching_folders, listCB, errback, timeout) |
| 1214 | else: |
| 1215 | errback(OperationFailure('Failed to delete %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history)) |
| 1216 | |
| 1217 | m = SMB2Message(SMB2TreeConnectRequest(r'\\%s\%s' % ( self.remote_name.upper(), service_name ))) |
| 1218 | self._sendSMBMessage(m) |
| 1219 | self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, connectCB, errback, path = service_name) |
| 1220 | self._pushToArray(messages_history, m) |
| 1221 | else: |
nothing calls this directly
no test coverage detected