Hi Tom,

--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#    Copyright (c) 2009-2015 Mike Revitt <m...@cougar.eu.com>
#    See the file LICENSE.txt for your rights.

import os.path
import subprocess
import datetime
import getpass
import weewx
from weewx.engine import StdService

# =============================================================================
#                    Class AWS_Sync
# =============================================================================

class S3_Sync(StdService):
    
    def run(self):
        
        if 'HTML_ROOT' in self.skin_dict:
            local_root = os.path.join(self.config_dict['WEEWX_ROOT'], self.skin_dict['HTML_ROOT'])
        else:
            local_root = os.path.join(self.config_dict['WEEWX_ROOT'], self.config_dict['StdReport']['HTML_ROOT'])
        
        if 'LOG_FILE' in self.skin_dict:
            log_file = self.skin_dict['LOG_FILE']
        else:
            log_file = "subprocess.PIPE"
        
        if 'DRY_RUN' in self.skin_dict:
            s3_cmd = 's3 sync --dryrun'
        else:
            s3_cmd = 's3 sync'
        
        s3_root       = self.skin_dict['S3_ROOT']
        aws           = self.skin_dict['AWS']
        cache_control = '--cache-control'
        cache_age     = 'max-age=120'       # 2 minutes
        
        LogFile = open(log_file, "a+")
        LogFile.write("\nWebsite Syncronisation Executed at %s by %s\n" %( datetime.datetime.now(), getpass.getuser()))
        
        command = subprocess.Popen([aws, s3_cmd, local_root, s3_root, cache_control, cache_age ], stdout = LogFile )
        
        LogFile.close()


Had a chance to look at this today and followed the example for Alarm.py 

I have created a file, awscli.py and copied in the code from reportengine.py that was previously working under a new class S3_Sync

I have added this line at the bottom of weewx.conf

report_services = weewx.engine.StdPrint, weewx.engine.StdReport, user.awscli.S3_Sync

and included a section with the heading [AwsCli]

when I run the program my new awscli.py compiles, and gives compilation errors if I invalidate some of the code, but at run time it is not being called. Currently all it does is open a log file and write a line of code to it which is not happening.

So I guess I have missed something. Any ideas


Mike Revitt

Global Database Cloud Migration Specialist

e: m...@cougar.eu.comp: +44.7825.063.466

On 29 Apr 2018, at 16:04, Thomas Keffer <tkef...@gmail.com> wrote:

Thanks, Mike! Very interesting.

A suggestion: rather than modify reportengine.py, with all the maintenance headaches that implies, you could put your new class AWS_Sync in a new file, say, user/aws_sync.py. Then subclass service StdReport, overriding its method launch_report_thread() to launch AWS_Sync instead of StdReportEngine.

This would make you more upgrade-proof.

-tk

On Sun, Apr 29, 2018 at 4:03 AM, Mike Revitt <m...@cougar.eu.com> wrote:
All,

I got this working a couple of months ago and have finally gotten around to documenting how I did it.

The guide is published here and you can see the Weewx website running at my domain, which is hosted on S3 or at the S3 address, both of which are shown below.



enjoy

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/fYg-cmVXAh0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to