This script uploads the contents of the ~/peakecoin and ~/Scala directories to the PeakeCoin FTP server under the /xlaswap directory.
I've been working a lot on the @Peakecoin project. I appreciate everyone that has been patient with me. It's not easy doing the solo mission.
📜 Script: ftp_upload.py
importosfromftplibimportFTP# FTP credentialsFTP_HOST="ftp.geocities.ws"FTP_USER=""FTP_PASS="P"# Directories to uploadDIRECTORIES_TO_UPLOAD={"peakecoin":os.path.expanduser("~/peakecoin"),"Scala":os.path.expanduser("~/Scala"),}# FTP Base DirectoryFTP_TARGET_DIR="/xlaswap"defensure_ftp_directory(ftp,path):"""Ensure that the directory exists on the FTP server."""directories=path.strip("/").split("/")current_path=""fordirectoryindirectories:current_path+=f"/{directory}"try:ftp.cwd(current_path)except:try:ftp.mkd(current_path)print(f"Created directory: {current_path}")ftp.cwd(current_path)exceptExceptionase:print(f"Error creating directory {current_path}: {e}")raisedefupload_directory(ftp,local_dir,ftp_dir):"""Upload the contents of a local directory to the FTP server."""ensure_ftp_directory(ftp,ftp_dir)foriteminos.listdir(local_dir):local_path=os.path.join(local_dir,item)ifos.path.isfile(local_path):print(f"Uploading file: {item}")withopen(local_path,"rb")asfile:ftp.storbinary(f"STOR {item}",file)elifos.path.isdir(local_path):print(f"Creating and uploading directory: {item}")upload_directory(ftp,local_path,f"{ftp_dir}/{item}")defmain():"""Main function to upload directories to FTP."""ftp=FTP(FTP_HOST)ftp.login(FTP_USER,FTP_PASS)ftp.set_pasv(True)# Enable passive modeforfolder_name,local_dirinDIRECTORIES_TO_UPLOAD.items():print(f"Uploading {local_dir} to {FTP_TARGET_DIR}/{folder_name} on the FTP server...")upload_directory(ftp,local_dir,f"{FTP_TARGET_DIR}/{folder_name}")ftp.quit()print("All uploads complete.")if__name__=="__main__":main()<br/>_ThisreportwaspublishedviaActifitapp([Android](https://bit.ly/actifit-app) | [iOS](https://bit.ly/actifit-ios)). Check out the original version [here on actifit.io](https://actifit.io/@strangedad/actifit-strangedad-20250221t033121740z)_