Archivo de copia de Python scp con espacios en el nombre del archivo

Estoy tratando de copiar archivos en la red local con scp. Funciona bien con nombres de archivos sin espacios, pero falla. He tratado de reemplazar "" con "\" ya que estoejemploPero no funciona. Aquí está mi código:

def connection(locals):
         a = (int(re.search(br'(\d+)%

Como puedo solucionar este problema ? Gracias

, locals['child'].after).group(1))) print a perc = (Decimal(a)/100) print (type(perc)), perc while gtk.events_pending(): gtk.main_iteration() FileCopy.pbar.set_text("Copy of the file in the Pi... " + str(a) + "%") while gtk.events_pending(): gtk.main_iteration() FileCopy.pbar.set_fraction(perc) file_pc = "/home/guillaume/folder/a very large name of file with space .smthg" file_pi = "[email protected]:/home/pi/folder/a very large name of file with space .smthg" if " " in file_pc: file_pc = fichier_pc.replace(" ", '\\\ ') # tried '\\ ' or '\ ' file_pi = fichier_pi.replace(" ", '\\\ ') # but no way else: pass command = "scp %s %s" % tuple(map(pipes.quote, [file_pc, file_pi])) pexpect.run(command, events={r'\d+%': connection}) # this command is using to get the %

Como puedo solucionar este problema ? Gracias

Respuestas a la pregunta(3)

Su respuesta a la pregunta