I have written a report to copy files to an AWS S3 bucket, separate thread 
on that, but now an trying to incorporate it into my deployment.

The easy way, and the way I have done it so far is to modify 
reportengine.py, but there must be a better way


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

class AWS_Sync(ReportGenerator):
    
    """Class for managing the "AWS generator".

    This will copy everything in the public_html subdirectory to a 
webserver."""

    def run(self):
        import weeutil.s3upload

        # determine how much logging is desired
        log_success = to_bool(search_up(self.skin_dict, 'log_success', 
True))

        t1 = time.time()
        try:
            local_root = os.path.join(self.config_dict['WEEWX_ROOT'],
                                      self.skin_dict.get('HTML_ROOT', 
self.config_dict['StdReport']['HTML_ROOT']))
            s3_data = weeutil.s3upload.S3Upload(
                bucket=self.skin_dict['bucket'],
                profile=self.skin_dict['profile'],
                local_root=local_root,
                remote_root=self.skin_dict['S3_ROOT'],
                name=self.skin_dict['REPORT_NAME'],
                debug=int(self.skin_dict.get('debug', 0)),
                secure_data=to_bool(self.skin_dict.get('secure_data', 
True)))
        except KeyError:
            syslog.syslog(syslog.LOG_DEBUG,
                          "AWS_Sync: AWS upload not requested. Skipped.")
            return

        try:
            n = s3_data.run()
        except (socket.timeout, socket.gaierror, ftplib.all_errors, 
IOError) as e:
            (cl, unused_ob, unused_tr) = sys.exc_info()
            syslog.syslog(syslog.LOG_ERR, "AWS_Sync: "
                                          "Caught exception %s: %s" % (cl, 
e))
            weeutil.weeutil.log_traceback("        ****  ")
            return

        if log_success:
            t2 = time.time()
            syslog.syslog(syslog.LOG_INFO,
                          "AWS_Sync: awscli S3'd %d files in %0.2f seconds" 
%
                          (n, (t2 - t1)))



Thoughts

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/78c88189-2052-4870-b078-3a40d68af8cd%40googlegroups.com.

Reply via email to