run a script after ftp upload

91 views
Skip to first unread message

Ian Boag

unread,
Mar 16, 2016, 10:08:12 PM3/16/16
to weewx-user
What it says. I want to run a bash script at the end of the upload. Is this one of those blindingly obvious things I have missed?

In case anyone wonders why - being a miser with data volumes and all that - I want to disconnect my cellular modem, then reconnect next time round. 

I can do it with a cron job of course but it would (to me) be more elegant to tack it on the end of the upload. 

Ian Boag

mwall

unread,
Mar 16, 2016, 10:31:00 PM3/16/16
to weewx-user
On Wednesday, March 16, 2016 at 10:08:12 PM UTC-4, Ian Boag wrote:
What it says. I want to run a bash script at the end of the upload. Is this one of those blindingly obvious things I have missed?

define your own version of the ftp generator.

1) in a new file user/boagftp.py, create a new class derived from the ftp generator class, something like this:

import weewx.reportengine

class BoagFtpGenerator(weewx.reportengine.FtpGenerator):
    def run(self):
        # turn modem on here, if necessary
        self.FtpGenerator.run()
        # turn modem off here

2) tell weewx to use your uploader with something like this in weewx.conf:

[StdReport]
    [[BoagFtp]]
        skin = boagftp

3) create the skin config file skins/boagftp/skin.conf:

[Generators]
    generator_list = user.boagftp.BoagFtpGenerator

4) restart weewx

m

Thomas Keffer

unread,
Mar 16, 2016, 10:31:13 PM3/16/16
to weewx-user
Sorry! There's no blindingly easy way to do this.

Probably would be easiest to forgo the FTP done by weewx and, instead, run your cron script which would do the connection, an independent FTP session, then disconnect.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ian Boag

unread,
Mar 21, 2016, 7:33:39 PM3/21/16
to weewx-user
Thanks. Seems pretty simple.

I currently run a cron that takes some pix and uploads them on the same cycle as the read-weather-station. Currently that cron runs just before the read-weather one.  All I actually need to upload from weewx is the index.html in weewx/public_html (I run a VERY simple site)

So I went in weewx.conf, commented out the ftp server details. Put the pic-take-cron just AFTER the read-weather-sation time and added an ftp for the index.html ......

Do I have this right?

IB

Ian Boag

unread,
Mar 23, 2016, 5:55:37 PM3/23/16
to weewx-user
Refined it a bit

The "take-and-upload-pics" script is set to run at the same time as the "read-weather-station" function.

I killed the ftp from weewx.

Now I fire off the pic-taker, take the pics, then run wee_reports to generate the site.

Then I connect the modem - upload the site (wput) and the pix (more wput) - disconnect the modem and wait for next time.

Seems to work :-)

IB
Reply all
Reply to author
Forward
0 new messages