MCPcopy Create free account
hub / github.com/RainingComputers/whipFTP / upload_dir

Method upload_dir

FTP_controller.py:200–225  ·  view source on GitHub ↗
(self, dir_name, status_command, replace_command)

Source from the content-addressed store, hash-verified

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

Callers 3

copy_dirMethod · 0.95
uploadMethod · 0.45
upload_dndMethod · 0.45

Calls 4

is_thereMethod · 0.95
upload_fileMethod · 0.95
cwdMethod · 0.80
mkdMethod · 0.45

Tested by

no test coverage detected