On Thursday, 13 February 2020 08:39:26 UTC+10, Mike Revitt wrote:
>
> That makes sense, I have created a skin with its own weewx.conf already,
> was struggling to work out how to call the generator in its own file
>
I suspect you mean its own skin.conf, your only connection to weewx.conf
will be that your skin will have it's own sub-section under [StdReport] in
weewx.conf.
> Do I then call it from the S3 conf file like this
>
> [Generators]
>
> generator_list = weeutil.s3upload.S3Upload
>
>
>
The structure is right but I think the detail is wrong. Let's take a step
back. You have created class S3Upload in s3upload.py in the weeutil
directory, this is the class that does the actual upload work. To perform
the S3 upload as a generator in a skin (al the FTP generator) you then need
to call a class based on class ReportGenerator, this appears to be your class
AWS_Sync in your first post. As I outlined above any code you add is best
located in the user directory (/home/weewx/bin/user or /usr/share/weewx/user
depending on your WeeWX install type) in order to survive WeeWX upgrades.
In your case there is no reason why you cannot place both classes in the
same file, let's say you place both in the file user/s3upload.py. In your
skin.conf you would call your generator with:
[Generators]
generator_list = user.s3upload.AWS_Sync
In your class AWS_Sync instead of using
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(
you would use
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:
local_root = os.path.join(self.config_dict['WEEWX_ROOT'],
self.skin_dict.get('HTML_ROOT', self.
config_dict['StdReport']['HTML_ROOT']))
s3_data = user.s3upload.S3Upload(
You then have everything contained in a single file that is survivable
across WeeWX upgrades. One other thing you might consider is renaming class
AWS_Sync, WeeWX uses the naming structure XxxxxxGenrator for its generator
classes, so something like class S3UploadGenerator might make it a bit more
obvious as to the purpose of the class (which aids others when they look at
your code later). Of course if you chnage the name of class AWS_Sync you
need to change the same in the examples I have used above.
Gary
--
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/0fecf613-0bc8-474c-a682-d1b92815b4aa%40googlegroups.com.