Commit 963ec115 authored by Ivan Mazhukin's avatar Ivan Mazhukin

just import…

just import https://gitlab.eterfund.ru/Gendalf4ever/co2/-/archive/co2-101/co2-co2-101.tar to co2-mt8057s subdir with rpmgs script
parent 5b6c20d0
config.ini
*.pyc
__pycache__/
\ No newline at end of file
from influxdb import InfluxDBClient from influxdb import InfluxDBClient
import os
from dotenv import load_dotenv
import time import time
#Загрузка файла с переменными окружения
load_dotenv('creds.env')
#Проверка
print("INFLUXDB_URL:", os.getenv('INFLUXDB_URL'))
print("INFLUXDB_DB:", os.getenv('INFLUXDB_DB'))
class InfluxConnection: class InfluxConnection:
def __init__(self): def __init__(self):
# Конфиги # Получение конфигурации из переменных окружения
self.INFLUXDB_URL = 'http://influxdb.k8s.eterfund.ru' self.INFLUXDB_URL = os.getenv('INFLUXDB_URL')
self.INFLUXDB_DB = '' self.INFLUXDB_DB = os.getenv('INFLUXDB_DB')
self.INFLUXDB_USER = '' self.INFLUXDB_USER = os.getenv('INFLUXDB_USER')
self.INFLUXDB_PASSWORD = '' self.INFLUXDB_PASSWORD = os.getenv('INFLUXDB_PASSWORD')
# Разделение URL на хост и порт # Разделение URL на хост и порт
url_parts = self.INFLUXDB_URL.split('://')[1].split(':') url_parts = self.INFLUXDB_URL.split('://')[1].split(':')
...@@ -23,7 +36,6 @@ class InfluxConnection: ...@@ -23,7 +36,6 @@ class InfluxConnection:
database=self.INFLUXDB_DB database=self.INFLUXDB_DB
) )
def write_data(self, sensor_id, values): def write_data(self, sensor_id, values):
json_body = [ json_body = [
{ {
...@@ -43,4 +55,3 @@ class InfluxConnection: ...@@ -43,4 +55,3 @@ class InfluxConnection:
def __del__(self): def __del__(self):
self.client.close() self.client.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment