PS. the logging library version is 0.5.1.2 and it seems I cannot update it 
because I get the error

ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python3.8 -c 'import io, os, sys, setuptools, 
tokenize; sys.argv[0] = 
'"'"'/tmp/pip-install-z4b_670u/logging_4bd977b2e0de45cb8530e2a3ad73a5cd/setup.py'"'"';
 
__file__='"'"'/tmp/pip-install-z4b_670u/logging_4bd977b2e0de45cb8530e2a3ad73a5cd/setup.py'"'"';f
 
= getattr(tokenize, '"'"'open'"'"', open)(__file__) if 
os.path.exists(__file__) else io.StringIO('"'"'from setuptools import 
setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' 
egg_info --egg-base /tmp/pip-pip-egg-info-6gg4rpp7
         cwd: 
/tmp/pip-install-z4b_670u/logging_4bd977b2e0de45cb8530e2a3ad73a5cd/
    Complete output (26 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", 
line 18, in <module>
        from setuptools.dist import Distribution
      File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", 
line 32, in <module>
        from setuptools.extern.more_itertools import unique_everseen
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in 
_find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 556, in module_from_spec
      File 
"/usr/local/lib/python3.8/site-packages/setuptools/extern/__init__.py", 
line 52, in create_module
        return self.load_module(spec.name)
      File 
"/usr/local/lib/python3.8/site-packages/setuptools/extern/__init__.py", 
line 37, in load_module
        __import__(extant)
      File 
"/usr/local/lib/python3.8/site-packages/setuptools/_vendor/more_itertools/__init__.py",
 
line 1, in <module>
        from .more import *  # noqa
      File 
"/usr/local/lib/python3.8/site-packages/setuptools/_vendor/more_itertools/more.py",
 
line 5, in <module>
        from concurrent.futures import ThreadPoolExecutor
      File "/usr/local/lib/python3.8/concurrent/futures/__init__.py", line 
8, in <module>
        from concurrent.futures._base import (FIRST_COMPLETED,
      File "/usr/local/lib/python3.8/concurrent/futures/_base.py", line 7, 
in <module>
        import logging
      File 
"/tmp/pip-install-z4b_670u/logging_4bd977b2e0de45cb8530e2a3ad73a5cd/logging/__init__.py",
 
line 618
        raise NotImplementedError, 'emit must be implemented '\
                                 ^
    SyntaxError: invalid syntax

On Saturday, 12 March 2022 at 11:17:13 UTC+1 Saverio Guzzo wrote:

> Hey community,
>
> I have a fleet of Davis weather stations connected to as many 
> RaspberryPis, on which I am running the vantage drivers as a standalone 
> program on docker container, deployed using Balena 
> <https://www.balena.io/open/>.
> I'd like my program to send data every minute to a REST API and I've been 
> looking into some way to get archive data from a in loop, but I'm not sure 
> I'm doing it the right way.
>
> What I did was defining in the driver's main method something like:
>
> *while True:*
> * since_ts = datetime.datetime.timestamp(datetime.datetime.now() - 
> datetime.timedelta(minutes=1))*
> * for packet in vantage.genDavisArchiveRecords(since_ts):*
> * try:*
> * new_packet = weewx.units.to_METRICWX(packet)*
> * davispusher.send_message(payload=new_packet)*
> * log.debug(davispusher.payload)*
> * except Exception as e:*
> * log.debug("Found an exception: %s" % e)*
> * time.sleep(1.2)*
> * continue*
> * time.sleep(60)*
>
> Where davispusher is an instance of a simple class that is needed to add 
> some values to the archive record and send the message and is defined as:
> *class DavisPusher:*
> * def __init__(self, host='https://mywebsite.somewhere 
> <https://mywebsite.somewhere>, port=8080, endpoint='davis'):*
> * self._endpoint = "{host}:{port}/{endpoint}".format(host=host, *
> * endpoint=endpoint,*
> * port=port)*
> * self.payload = {}*
>
> * def format_message(self,*
> * payload: dict,*
> * sensor_id: str = environ['SENSOR_ID'],*
> * latitude: str = environ['LATITUDE'],*
> * longitude: str = environ['LONGITUDE'],*
> * altitude: str = environ['ALTITUDE'],*
> * ) -> dict:*
> * """Formats message for backend."""*
>
> * payload_copy = payload.copy()*
> * try:*
> * self.payload = payload_copy*
> * self.payload['sensor_id'] = sensor_id*
> * self.payload['altitude'] = float(altitude)*
> * self.payload['longitude'] = float(longitude)*
> * self.payload['latitude'] = float(latitude)*
>
> * except Exception:*
> * self.payload = {}*
> * def send_message(self, payload):*
> * '''formats and sends message to backend'''*
> * self.format_message(payload)*
> * resp = requests.post <http://requests.post>(self._endpoint, data = 
> json.dumps(self.payload), allow_redirects = True)*
> * log.debug("got HTTP statuscode %s", resp.status_code)*
>
> However, my logs are full of logging errors ("Bad file descriptor", "File 
> "/usr/local/lib/python3.8/logging/handlers.py" No such file or directory")
> I guess those are errors due to logging configuration, but I'm not sure 
> how to address them. I created a GitHub Gist 
> <https://gist.github.com/saveriogzz/c624c03e63a3be3d66daf57b25337b7e> in 
> order not to pollute this post!
>
> Also, what I would like to achieve is the possibility to configure the 
> various consoles (set time, set coordinates) at startup using environment 
> variables. How could I do this using the VantageConfigurator class?
>
> Thanks a lot in advance for your help, I'm kind of alone in my work and 
> I'd really appreciate your help.
>
> Friendly greetings,
> Saverio
>

-- 
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/ef48419b-a696-4573-8609-f3af3d0badb6n%40googlegroups.com.

Reply via email to