(self, dir_name, status_command, replace_command)
| 198 | file_to_up.close() |
| 199 | |
| 200 | def upload_dir(self, dir_name, status_command, replace_command): |
| 201 | #Change to directory |
| 202 | os.chdir(dir_name) |
| 203 | #Create directory in server and go inside |
| 204 | try: |
| 205 | if(not self.is_there(dir_name)): |
| 206 | self.ftp.mkd(dir_name) |
| 207 | status_command(dir_name, 'Creating directory') |
| 208 | else: |
| 209 | status_command(dir_name, 'Directory exists') |
| 210 | self.ftp.cwd(dir_name) |
| 211 | except: |
| 212 | status_command(dir_name, 'Failed to create directory') |
| 213 | return |
| 214 | #Cycle through items |
| 215 | for filename in os.listdir(): |
| 216 | #If file upload |
| 217 | if(isfile(filename)): |
| 218 | self.upload_file(filename, os.path.getsize(filename), status_command, replace_command) |
| 219 | #If directory, recursive upload it |
| 220 | else: |
| 221 | self.upload_dir(filename, status_command, replace_command) |
| 222 | |
| 223 | #Got to parent directory |
| 224 | self.ftp.cwd('..') |
| 225 | os.chdir('..') |
| 226 | |
| 227 | def download_file(self, ftp_file_name, file_size, status_command, replace_command): |
| 228 | #Function for updating status and writing to file |
no test coverage detected