RSUDP FTP Upload Module


We have a Raspberry Shake at our school and run RSUDP in a Raspberry Pi, which we access through VNC (only way to bypass the school’s firewall limitations).

We have a server (accessible anywhere since it’s outside the school’s network) which we’re using as an FTP Server, kind of like our own private Google Drive. From here we distribute images and files to our websites.

Is it possible to do the following using RSUDP:

  1. It senses a movement and sends the Alert message
  2. Once the plot module takes the screenshot:
    a. Send the image to the FTP Server (using ftplib on python)
    b. Register that image in our Database (I have created a function that registers every image uploaded to the FTP Server and its path to make it easier to work with in the website)

I found the part in the RSUDP code that takes the screenshot (savefig) and sends its information to the other modules (Telegram, Twitter, etc) but don’t know if it’s possible for me to connect an external function I create in that part. I was thinking of doing a sync program that synced the rsudp/screenshots folder with the FTP folder and running it with CRON, but then figured it would be best to just upload each image as soon as they are created.

Could I perhaps import our own Python module into the RSUDP Plot module and call the FTP upload function in that part? Or is it better to develop the module and receive the image just as the Telegram and Twitter modules do?

I appreciate any advice.

1 Like

That’s a good question. Importing your own module into the Plot module is possible but is not a desirable solution, since the speed of the FTP transfer directly impacts the speed at which the plot is able to redraw. Additionally if the FTP transfer has an error then it may end up crashing the master thread, which runs the plot module.

One of the cool things about the way rsudp is constructed is that it creates individual subordinate threads for each task (i.e. Twitter, Telegram, the AlertSound, and others) so that if one of them has an error it doesn’t stop any of the other ones. (see image)

My suggestion would be to build a consumer that looks for IMGPATH messages on its queue, then uses the path to send the file via ftplib as you suggest. We have a bunch of information on creating your own consumer module in our developer guide. In that guide there is sample code for a custom consumer, which gets you like 80% of the way there. This is a good intermediate level coding project.

If you write code for this we would love for you to create a pull request so that your contribution can be included, and you can be listed as a contributing author.

If you have questions about the process, I’d be happy to help.

1 Like

Hi Ian!

Thank you so much for your help! I spent some time going through the code to see how it works and got a good understanding of the workflow, along with the documentation. I created the consumer module and set up some placeholder variables to configure the rs-test. Today I will incorporate the ftplib using as a reference the Telegram module.

Sure, I will definitely create a pull request once I get it working efficiently.

Thank you again, I’ll keep you updated.

1 Like