Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel2
Web
Commits
594f7de6
Commit
594f7de6
authored
1 month ago
by
Gezer
Browse files
Options
Download
Email Patches
Plain Diff
cleaned fixed print statements
parent
fa5008bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/stream_processing/mQTTClientHandler.py
+0
-8
backend/stream_processing/mQTTClientHandler.py
backend/utils/influx.py
+1
-11
backend/utils/influx.py
with
1 addition
and
19 deletions
+1
-19
backend/stream_processing/mQTTClientHandler.py
+
0
-
8
View file @
594f7de6
...
...
@@ -9,7 +9,6 @@ import os
class
MQTTClientHandler
:
MAPPING_FILE_NAME
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"mac_to_room.json"
...
...
@@ -41,7 +40,6 @@ class MQTTClientHandler:
self
.
logger
.
info
(
"Connected with result code "
+
str
(
rc
))
client
.
subscribe
(
self
.
topic
)
self
.
logger
.
info
(
"Subscribed to "
+
self
.
topic
)
print
(
"Connected with result code "
+
str
(
rc
)
+
"
\n
"
+
"Subscribed to "
+
self
.
topic
)
# eventuell refactorn und die Aufgaben in Methoden aufteilen
def
on_message
(
self
,
client
,
userdata
,
msg
):
...
...
@@ -62,7 +60,6 @@ class MQTTClientHandler:
self
.
logger
.
warning
(
f
"Neue MAC-Adresse gefunden:
{
mac
}
. Mapping wird ergänzt."
)
print
(
f
"Neue MAC-Adresse gefunden:
{
mac
}
. Mapping wird ergänzt."
)
self
.
mac_to_room
[
mac
]
=
""
# leerer Platzhalter
jsonhandler
.
write_json
(
self
.
mac_to_room
,
self
.
MAPPING_FILE_NAME
)
self
.
mac_to_room
=
jsonhandler
.
load_json
(
self
.
MAPPING_FILE_NAME
)
...
...
@@ -88,12 +85,7 @@ class MQTTClientHandler:
self
.
logger
.
info
(
f
"Wrote to InfluxDB:
{
msg
}
"
)
print
(
f
"Token:
{
self
.
influx_writer
.
get_token
()
}
"
)
print
(
f
"Url:
{
self
.
influx_writer
.
get_url
()
}
"
)
print
(
f
"Wrote to InfluxDB:
{
msg
}
"
)
print
(
f
"Ping:
{
self
.
influx_writer
.
ping
()
}
"
)
except
Exception
as
e
:
print
(
f
"Failed writing to InfluxDb:
{
e
}
"
)
self
.
logger
.
error
(
f
"Failed writing to InfluxDb:
{
e
}
"
)
def
start
(
self
):
...
...
This diff is collapsed.
Click to expand it.
backend/utils/influx.py
+
1
-
11
View file @
594f7de6
...
...
@@ -5,8 +5,6 @@ from influxdb_client.client.write_api import WriteOptions
class
InfluxDBHelper
:
def
__init__
(
self
,
url
:
str
,
token
:
str
,
org
:
str
,
bucket
:
str
):
self
.
url
=
url
self
.
token
=
token
self
.
client
=
InfluxDBClient
(
url
=
url
,
token
=
token
,
org
=
org
)
self
.
bucket
=
bucket
self
.
org
=
org
...
...
@@ -28,16 +26,8 @@ class InfluxDBHelper:
if
timestamp
:
point
.
time
(
timestamp
,
WritePrecision
.
NS
)
self
.
write_api
.
write
(
bucket
=
self
.
bucket
,
org
=
self
.
org
,
record
=
point
)
def
get_token
(
self
):
return
self
.
token
def
get_url
(
self
):
return
self
.
url
def
ping
(
self
):
def
ping
(
self
)
->
bool
:
return
self
.
client
.
ping
()
def
get_all_data
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets