sftp not working correctly
AskAlice opened this issue · 0 comments
AskAlice commented
BambuHMI/bambuhmi_codebase/setup.py
Lines 31 to 56 in 3885927
I had to patch with this, however it adds a dep of sshpass
def upload_files():
if messagebox.askokcancel("Confirmation", "This will install all the files within /functions/Installed_machineMacros/macros & sh folders to the printer."):
try:
# Upload files from /functions/Installed_machineMacros/macros to /mnt/sdcard/x1plus/macros/
macros_source = './functions/Installed_machineMacros/macros'
macros_target = '/mnt/sdcard/x1plus/'
#template in PRINTER_IP and PRINTER_USERNAME
subprocess.run(['sshpass', '-p', PRINTER_PASSWORD, 'scp', '-r', macros_source, f'{PRINTER_USERNAME}@{PRINTER_IP}:{macros_target}'], check=True)
# Upload files from /functions/Installed_machineMacros/sh to /usr/bin
sh_source = 'functions/Installed_machineMacros/sh'
sh_target = '/usr/bin'
for file in os.listdir(sh_source):
subprocess.run(['sshpass', '-p', PRINTER_PASSWORD, 'scp', os.path.join(sh_source,file), f'{PRINTER_USERNAME}@{PRINTER_IP}:{sh_target}'], check=True)
messagebox.showinfo("Success", "Files uploaded successfully!")
except Exception as e:
messagebox.showerror("Error", f"Failed to upload files: {e}")