This script downloads files from an FTP server, processes XML files, and monitors a local directory for new files. It utilizes threading to handle FTP downloads and directory monitoring concurrently.
- Python 3.x
ftplib
,watchdog
, andxml.etree.ElementTree
libraries (these are standard Python libraries, butwatchdog
needs to be installed via pip)- Docker for running the FTP server
To set up the FTP server, you can use the fauria/vsftpd
Docker image. Here are the steps:
- Run the FTP server:
docker-compose up -d
To upload files to the FTP server, you can use the curl
command. Here are the steps:
-
Make sure you have
curl
installed. If not, install it using your package manager (e.g.,apt
,yum
,brew
). -
Upload a file to the FTP server:
curl -T <your_file_path> ftp://localhost:21 --user nybsys:12345
Replace
<your_file_path>
with the path to the file you want to upload.
To run the script, follow these steps:
-
Make sure you have Python installed.
-
Install the required Python package
watchdog
:pip install watchdog
-
Run the script:
python file_processor.py
This README provides instructions on setting up an FTP server using Docker, uploading files using curl
, and running the Python script to download, process, and monitor XML files.