PK!H 22aiotelegraf/__init__.pyfrom .client import Client __all__ = ("Client",) PK!Ԧaiotelegraf/client.pyimport asyncio from asyncio.transports import DatagramTransport from typing import Any, Optional from telegraf.client import ClientBase __all__ = ("Client",) class Client(ClientBase): __slots__ = ("_protocol",) def __init__( self, *, host: str = "localhost", port: int = 8094, tags: Optional[dict] = None ) -> None: super().__init__(host=host, port=port, tags=tags) self._protocol = DatagramProtocol() async def connect(self) -> None: loop = asyncio.get_event_loop() await loop.create_datagram_endpoint( lambda: self._protocol, remote_addr=(self.host, self.port) ) async def close(self) -> None: self._protocol.close() def metric( self, measurement_name: str, values: Any, *, tags: Optional[dict] = None, timestamp: Optional[int] = None, ) -> None: super().metric(measurement_name, values, tags=tags, timestamp=timestamp) def send(self, data: str) -> None: self._protocol.send(data) class DatagramProtocol(asyncio.DatagramProtocol): __slots__ = ("_transport",) def __init__(self) -> None: self._transport: Optional[DatagramTransport] = None def close(self) -> None: if self._transport is None: return self._transport.close() def connection_made(self, transport): self._transport = transport def connection_lost(self, _exc): self._transport = None def send(self, data: str) -> None: if self._transport is None: return try: self._transport.sendto(f"{data}\n".encode("utf-8")) except: # noqa: E722 # Errors should fail silently so they don't affect anything else pass PK!=-//#aiotelegraf-0.2.0.dist-info/LICENSEMIT License Copyright (c) 2018 Nikita Grishko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!H_zTT!aiotelegraf-0.2.0.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]n0H*J>mlcAPK!Hp{-b $aiotelegraf-0.2.0.dist-info/METADATAVmo6_qC6,IYtX} gHʎ0HIE*wϽ=w:3?Xd 'qt*LqP`a:ϓdUL™mdv>4T2Q:X+ee:3 Nm0֬ 'sڦY]YLUz6tg(-)_]FcS&մכrlIocp[nT'b\PcF=A)4y1}#}.|͑ M%ib)(ΪeydQS~W)1vu6)8rc3Vton;`i׾*xtICzI{-xX_7+yV @mGSHTewuRH$oBOމ\`e9ҚPK!H/|*"aiotelegraf-0.2.0.dist-info/RECORD};0޳D [IDOS,જ~+g|x)Ʋ)OHֲ1I *E"qJYC bټM[j0_ȣN@mV%7=R:Oj".Llꌢ(s}oݘ?/m9A`8g[ئFvyJtE<Zhcճ  ![Љ[++\C04&Yr01sufF }]9PK!H 22aiotelegraf/__init__.pyPK!Ԧgaiotelegraf/client.pyPK!=-//#aiotelegraf-0.2.0.dist-info/LICENSEPK!H_zTT! aiotelegraf-0.2.0.dist-info/WHEELPK!Hp{-b $ aiotelegraf-0.2.0.dist-info/METADATAPK!H/|*"aiotelegraf-0.2.0.dist-info/RECORDPK{