On Friday, December 22, 2017 at 6:26:23 PM UTC-5, Joe Percival wrote:
>
> Can I use this mechanism to store and retrieve credentials and other 
> parameters?
> In the extension’s skin include an [Extras] field under which I could have 
> various parameters. for example:
> [Extras]
> snowIP=‘192.168.1.###’
> snowUser=‘me’
> snowPW=‘password’
> snowMAXmm=2438
>
> then, in the extension I can grab the parameters using something like:
> snowIP=self.skin_dict['Extras'][’snowIP’]
>

that would work if the extension is a skin, or a skin component such as a 
search list extension or a generator.

but if the extension is a service, you probably want this in the config:

[SnowService]
    address = 192.168.1.55
    username = theuser
    password = thepassword
    max_mm = 2438

then in the snow service code (python) you'll have something like this:

class SnowService(StdService):
    def __init__(self, engine, config_dict):
        super(SnowService, self).__init__(engine, config_dict)
        snow_dict = config_dict.get('SnowService', {})
        self.max_mm = int(snow_dict.get('max_mm', 2000))
        try:
            self.address = snow_dict['address']
            self.username = snow_dict['username']
            self.password = snow_dict['password']
        except KeyError, e:
            raise Exception("missing parameter '%s'" % e)

 then you can use self.address, self.username, etc wherever you need them 
in the other methods of SnowService.

m

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

Reply via email to