I'd like to know how to download all data from a ftp dir to a folder in my operation system, but when I try to use a folder/path as a writible object python returns me an exception of permission diened.
My trial:
# os.chdir(self.dir_data_base + '\\Thrash')
# try:
# load_workbook('relatorio.xlsx').save('relatorio.xlsx')
# except:
# messagebox.showerror('Erro','Você não pode realizar qualquer operação com um dos seguintes arquivos abertos: relatorio.xlsx, Historico_de_lançamentos.xlsx')
# return False
# try:
# load_workbook('Historico_de_lançamentos.xlsx').save('Historico_de_lançamentos.xlsx')
# except:
# messagebox.showerror('Erro','Você não pode realizar qualquer operação com um dos seguintes arquivos abertos: relatorio.xlsx, Historico_de_lançamentos.xlsx')
# return False
# os.chdir(self.dir_data_base)
# ftp = ftplib.FTP(timeout=30)
# ftp.connect('any.com.br')
# ftp.login('username','pass')
# backup_name = self.aux_function_erase_blank_space(self.restore.get())
# ftp.cwd('/Banco de dados/' + backup_name)
# filenames = ftp.nlst() # get filenames within the directory
# for filename in filenames:
# local_filename = self.dir_data_base
# file = open(local_filename, 'wb')
# ftp.retrbinary('RETR '+ filename, file.write)
# file.close()
# ftp.quit() # This is the “polite” way to close a connection
PS: the original code is into a big project compacted into a class, so you see self