That is good news.

As for adding to WeeWX, typically only services/drivers etc that are/will 
be widely used are added to the code base. Anything else is maintained 
externally by the author and made available as they see fit, that can be 
anything from a few scratchie bits of code and some instructions on a web 
page somewhere through to a WeeWX extension that can be easily 
installed/managed/removed by the user using the wee_extension utility. 
Extensions etc are commonly listed in the WeeWX wiki 
<https://github.com/weewx/weewx/wiki> (anyone can edit/add to the wiki) 
with a link to any source files/extension packages (the WeeWX wiki is great 
for documenting instructions etc but does not store files as such). Many of 
us host our code on GitHub <https://github.com/> (just search for weewx in 
GitHub) and many of the extensions you will find in the wiki have links to 
GitHub repos.

Gary

On Monday, 17 February 2020 02:25:24 UTC+10, Mike Revitt wrote:
>
> Thanks for all your help Gary,
>
> That did the trick, Just fixed all off the error handling today, now that 
> I have it running, and am ready to package it up and put my new website 
> live.
>
> What is the process for adding a plugin to weewx?
>
> Mike
> On Sunday, February 16, 2020 at 8:02:05 AM UTC, gjr80 wrote:
>>
>> Mike,
>>
>> The generator_list setting should contain one or more references to 
>> generator classes to be used, ie classes that are based on class 
>> ReportGenerator. Given your code that would be S3UploadGenerator, so 
>> something like:
>>
>> [Generators]
>>
>>     generator_list = user.s3upload.S3UploadGenerator
>>
>> should do the trick.
>>
>> Gary
>>
>> On Sunday, 16 February 2020 00:29:13 UTC+10, Mike Revitt wrote:
>>>
>>> You have been super helpful so far Gary, so bear with me, I am almost 
>>> there.
>>>
>>> My program is now called S3UploadGenerator and is in the bin/user 
>>> directory. I have also successfully installed weewx 4.0 on my raspberry 
>>> pi using python3, which is also now the default
>>>
>>> Calling it from the command line now works perfectly and I also 
>>> successfully call it when running weewxd 
>>>
>>> But: 1 error remains when s3upload.py is called:
>>>
>>> Traceback (most recent call last):
>>>   File "/home/weewx/bin/weewx/reportengine.py", line 202, in run
>>>     obj.start()
>>> AttributeError: 'S3Upload' object has no attribute 'start'
>>> Exception in thread ReportThread:
>>> Traceback (most recent call last):
>>>   File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
>>>     self.run()
>>>   File "/home/weewx/bin/weewx/reportengine.py", line 215, in run
>>>     obj.finalize()
>>> AttributeError: 'S3Upload' object has no attribute 'finalize'
>>>
>>>
>>> I have searched the manuals and looked at all of the existing code and 
>>> can't work out what to do to resolve this.
>>>
>>> my S3/skin.conf contains the following:
>>>
>>> [Generators]
>>>     generator_list = user.s3upload.S3Upload
>>>
>>>
>>> This is the relevant part of s3upload.py
>>> import logging
>>> import os
>>> import sys
>>> import time
>>> import boto3
>>>
>>> from    weewx.reportengine  import ReportGenerator
>>> from    six.moves           import cPickle
>>>
>>> log = logging.getLogger(__name__)
>>>
>>> # 
>>> =============================================================================
>>> #                    Class S3UploadGenerator
>>> # 
>>> =============================================================================
>>> class S3UploadGenerator(ReportGenerator):
>>>     
>>>     """Class for managing the "AWS generator".
>>>
>>>     This will copy everything in the public_html subdirectory to a 
>>> webserver."""
>>>     
>>>     def run(self):
>>>         import user.s3upload
>>>
>>>         # determine how much logging is desired
>>>         log_success = to_bool(search_up(self.skin_dict, 'log_success', 
>>> True))
>>>
>>>         t1 = time.time()
>>>         try:
>>>             S3_upload = 
>>> user.s3upload.S3Upload(bucket=self.skin_dict['S3_BUCKET'],
>>>                                             
>>> profile=self.skin_dict['AWS_Profile'],
>>>                                           
>>>   html_root=self.config_dict['StdReport']['HTML_ROOT'],
>>>                                             
>>> remote_root=self.skin_dict['S3_ROOT'],
>>>                                             
>>> name=self.skin_dict['REPORT_NAME'])
>>>         except KeyError:
>>>             syslog.syslog(syslog.LOG_DEBUG,
>>>                           "S3UploadGenerator: AWS upload not requested. 
>>> Skipped.")
>>>             return
>>>
>>>         try:
>>>             n = S3_upload.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, "S3UploadGenerator: "
>>>                                           "Caught exception %s: %s" % 
>>> (cl, e))
>>>             weeutil.weeutil.log_traceback("        ****  ")
>>>             return
>>>
>>>         if log_success:
>>>             t2 = time.time()
>>>             syslog.syslog(syslog.LOG_INFO,
>>>                           "S3UploadGenerator: AWS-S3 S3'd %d files in 
>>> %0.2f seconds" %
>>>                           (n, (t2 - t1)))
>>>
>>>
>>>
>>> And this is the main, which works from the command line
>>> # 
>>> =============================================================================
>>> #                    Main
>>> # 
>>> =============================================================================
>>> if __name__ == '__main__':
>>>     import configobj
>>>
>>>     import weewx
>>>     import weeutil.logger
>>>
>>>     weewx.debug = 1
>>>
>>>     weeutil.logger.setup('S3upload', {})
>>>     
>>>     if len(sys.argv) < 2:
>>>         print("""Usage: s3upload.py path-to-configuration-file 
>>> [path-to-be-ftp'd]""")
>>>         sys.exit(weewx.CMD_ERROR)
>>>
>>>     try:
>>>         config_dict = configobj.ConfigObj(sys.argv[1], file_error=True, 
>>> encoding='utf-8')
>>>     except IOError:
>>>         print("Unable to open configuration file %s" % sys.argv[1])
>>>         raise
>>>
>>>     S3_upload = S3Upload(config_dict['StdReport']['AWS-S3']['S3_BUCKET'],
>>>                         
>>>  config_dict['StdReport']['AWS-S3']['AWS_Profile'],
>>>                          config_dict['StdReport']['HTML_ROOT'],
>>>                          config_dict['StdReport']['AWS-S3']['S3_ROOT'],
>>>                          'S3')
>>>                          
>>>     print(config_dict['StdReport']['AWS-S3']['S3_BUCKET'],
>>>     config_dict['StdReport']['AWS-S3']['AWS_Profile'],
>>>     config_dict['WEEWX_ROOT'],
>>>     config_dict['StdReport']['AWS-S3']['S3_ROOT'],
>>>     'S3')
>>>     S3_upload.run()
>>>
>>>
>>> And this is the relevant section of weewx.conf
>>>     [[AWS-S3]]
>>>         # Using AWSCLI to copy the results to a webserver is treated as 
>>> just
>>>         # another report, albeit one with an unusual report generator!
>>>         skin = S3
>>>         enable = true
>>>
>>>         # You must configure AWS at the command line and create some 
>>> logon credentials
>>>         # in the credentials file. This is the name of the profile 
>>> defined in that
>>>         # file that you wish to use for the copy
>>>         AWS_Profile = mike
>>>
>>>         # This is the name of the S3 bucket where the files will be 
>>> copied
>>>         S3_BUCKET = s3-archive.revittmk.aws.co.uk
>>>
>>>         # This is the folder into which the files will be copied within 
>>> the S3 bucket,
>>>         S3_ROOT = /MountWeather
>>>
>>>
>>>
>>>
>>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/8adc27ee-4cfe-460e-9a72-3c9aca7ab5e9%40googlegroups.com.

Reply via email to