(self, ftp_dir_name, status_command, replace_command)
| 253 | file_to_down.close() |
| 254 | |
| 255 | def download_dir(self, ftp_dir_name, status_command, replace_command): |
| 256 | #Create local directory |
| 257 | try: |
| 258 | if(not os.path.isdir(ftp_dir_name)): |
| 259 | os.makedirs(ftp_dir_name) |
| 260 | status_command(ftp_dir_name, 'Created local directory') |
| 261 | else: |
| 262 | status_command(ftp_dir_name, 'Local directory exists') |
| 263 | os.chdir(ftp_dir_name) |
| 264 | except: |
| 265 | status_command(ftp_dir_name, 'Failed to create local directory') |
| 266 | return |
| 267 | #Go into the ftp directory |
| 268 | self.ftp.cwd(ftp_dir_name) |
| 269 | #Get file lists |
| 270 | detailed_file_list = self.get_detailed_file_list(True) |
| 271 | file_list = self.get_file_list(detailed_file_list) |
| 272 | for file_name, file_details in zip(file_list, detailed_file_list): |
| 273 | #If directory |
| 274 | if(self.is_dir(file_details)): |
| 275 | self.download_dir(file_name, status_command, replace_command) |
| 276 | #If file |
| 277 | else: |
| 278 | self.download_file(file_name, int(self.get_properties(file_details)[3]), status_command, replace_command) |
| 279 | #Got to parent directory |
| 280 | self.ftp.cwd('..') |
| 281 | os.chdir('..') |
| 282 | |
| 283 | def search(self, dir_name, status_command, search_file_name): |
| 284 | #Go into the ftp directory |
no test coverage detected