pywws.service.sftp

Upload files to a web server by SFTP.

This module uploads files to (typically) a website via SFTP. Details of the upload destination are stored in the file weather.ini in your data directory. You should be able to get the required information from your web space provider. If your provider doesn’t allow SFTP then use pywws.service.ftp instead.

  • Additional dependency: https://www.paramiko.org/ v2.1.0 or later

  • Example weather.ini configuration:

    [sftp]
    site = ftp.xxxx.yyyy.co.uk
    user = xxxxxxx
    directory = public_html/weather/data/
    port = 22
    password =
    privkey = /home/pywws/.ssh/webhost_rsa
    
    [hourly]
    plot = ['24hrs.png.xml', 'rose_12hrs.png.xml']
    text = ['24hrs.txt']
    services = [('sftp', '24hrs.txt', '24hrs.png', 'rose_12hrs.png')]
    

Paramiko can be installed with pip:

sudo pip install paramiko

Run pywws.service.sftp once to set the default configuration, which you can then change. directory is the name of a directory in which all the uploaded files will be put. This will depend on the structure of your web site and the sort of host you use. port is the port number to use. 22 is the standard value but your web space provider may require a different port.

Authentication can be by password or RSA public key. To use a key you first need to create a passwordless key pair using ssh-keygen, then copy the public key to your web space provider. For example:

ssh-keygen -t rsa -f webhost_rsa
ssh-copy-id -i webhost_rsa.pub xxxxxxx@ftp.xxxx.yyyy.co.uk

Move both key files to somewhere convenient, such as /home/pywws/.ssh/ and set privkey to the full path of the private key.

You can upload any files you like, as often as you like, but typical usage is to update a website once an hour. Each file to be uploaded needs to be listed in a service entry like ('sftp', 'filename'). If the file is not in your work directory’s output directory then filename should be the full path.

Classes

ToService(context[, check_params])


Comments or questions? Please subscribe to the pywws mailing list http://groups.google.com/group/pywws and let us know.