Multipe FTP-locations

321 views
Skip to first unread message

Per Edström

unread,
Sep 21, 2015, 7:13:40 AM9/21/15
to weewx-user
I currently upload "my" weather images etc to a password-protected site but now I want to share some stuff to the public i.e. to an open web server. So I want Weewx to first upload alla images and web pages to one site and then just some of the images to another site. How do I go about doing that? Seems a bit tricky or..?

Thomas Keffer

unread,
Sep 21, 2015, 8:38:48 AM9/21/15
to weewx-user
Hello, Per

Unfortunately, the present engine is just single-destination. 

You've got a couple of choices. The simplest would be to just kick off a separate process to run an external FTP session to the open web server.

Alternatively, if you're handy with Python, you could modify reportengine.FtpGenerator so it can recognize multiple sub-sections in section [FTP], one for each destination. Fork, modify, then I'd be happy to take a look at a pull request.

But, at this point, I just don't have the time myself. 

Seems like a reasonable feature.

-tk



On Mon, Sep 21, 2015 at 4:13 AM, Per Edström <peredst...@gmail.com> wrote:
I currently upload "my" weather images etc to a password-protected site but now I want to share some stuff to the public i.e. to an open web server. So I want Weewx to first upload alla images and web pages to one site and then just some of the images to another site. How do I go about doing that? Seems a bit tricky or..?

--
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.

Per Edström

unread,
Sep 23, 2015, 7:24:27 AM9/23/15
to weewx-user
Hi Tom!

I found this in fptupload.py:

"name: A unique name to be given for this FTP session. This allows more
        than one session to be uploading from the same local directory. [Optional.
        Default is 'FTP'.]
"

What if I just add another [[Ftp]]-section in weewx.conf? I guess weewx checks each section if it should be used? Then add a new skin-directory with the modified content for that session?
Weewx should take one FTP first and then the next in line..

Thomas Keffer

unread,
Sep 23, 2015, 8:51:54 AM9/23/15
to weewx-user
Of course! Silly me! Just add an extra FTP session to the skin:

[StdReport]

    ...    

    [[StandardReport]]
        skin = Standard
    
    [[FTP]]
        skin = Ftp
        user = joe
        password = joespassword
        server = localhost
        path = /weather
        #HTML_ROOT = public_html
        
    [FTP2]]
        skin = AnotherFtp
        # If you wish to use FTP, uncomment and fill out the next four lines.
        user = barney
        password = barneyspassword
        server = www.myopenserver.com
        path = /theweather
        #HTML_ROOT = public_html

Then copy the contents of directory skins/Ftp to skins/AnotherFtp. You can adjust the values of HTML_ROOT to control what the two sessions will copy, but only at a directory level.

Let me know how that works out.

-tk




Per Edström

unread,
Sep 23, 2015, 10:42:32 AM9/23/15
to weewx-user
Yes! It worked!

"
Sep 23 16:30:47 eBox3350 weewx[6276]: cheetahgenerator: Generated 15 files for report StandardReport1 in 34.67 seconds
Sep 23 16:30:57 eBox3350 weewx[6276]: cheetahgenerator: Generated 15 files for report StandardReport in 37.04 seconds
Sep 23 16:31:24 eBox3350 weewx[6276]: manager: added record 2015-09-23 16:31:00 CEST (1443018660) to database '/var/lib/weewx/weewx.sdb'
Sep 23 16:31:24 eBox3350 weewx[6276]: manager: added record 2015-09-23 16:31:00 CEST (1443018660) to daily summary in '/var/lib/weewx/weewx.sdb'
Sep 23 16:31:25 eBox3350 weewx[6276]: genimages: Generated 21 images for StandardReport in 28.49 seconds
Sep 23 16:31:33 eBox3350 weewx[6276]: reportengine: ftp'd 77 files in 7.65 seconds
Sep 23 16:31:43 eBox3350 weewx[6276]: wmr200: MainThread: W Rain sensor: Battery low
"

I copied "Standard"-folder to a new folder and used that to the second FTP-session. No need to create another FTP-skin as it just used the values here. In the nre report-skin I could remove images in skins.conf and edit index.hitml.tmpl so that the page doesn't show internal values etc.
Then I changed weewx.conf to:


"
    [[StandardReport]]
        skin = Standard
    [[FTP]]
        skin = Ftp
        secure_ftp = False
        HTML_ROOT = /var/www/weewx/ftp
        port = 21
        passive = 1
        max_tries = 3
        user = uid
        password = psw
        server = ftp.foo.bar
        path = /ftp

    [[StandardReport1]]
        skin = Standard1
        HTML_ROOT = /var/www/weewx/ftp1
    [[FTP1]]
        skin = Ftp
        secure_ftp = False
        HTML_ROOT = /var/www/weewx/ftp1
        port = 21
        passive = 1
        max_tries = 3
        user = uid
        password = psw
        server = ftp.foo.bar
        path = /ftp1
"

Thomas Keffer

unread,
Sep 23, 2015, 11:01:14 AM9/23/15
to weewx-user
I guess I wasn't as dumb as I thought. :-)

-tk

Per Edström

unread,
Sep 23, 2015, 3:45:52 PM9/23/15
to weewx-user
Nope - a quick a fully working solution!

The only thing is that the FTP-session is not disconnected between the two sessions, I guess as it is the same server the files should be uploaded to, but this means that the second FTP-transfer is made with the first directory set as "root". So if the first FTP have path = /foo and the second FTP have path = /bar, then the first FTP-files will end up in "/foo" but the second FTP-files will end up in "/foo/bar/".

So now I had to have path = ../bar in the second FTP for the files to end up in "/bar/" relative to the FTP-server start-directory.

Maybe there is a way to terminate the FTP-session and force it to start again for the next upload?
Reply all
Reply to author
Forward
0 new messages