Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try relative imports of tahu files if global import fails #27

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion enki.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import argparse
import signal

from sparkplug_b_pb2 import Payload
try:
from sparkplug_b_pb2 import Payload
except ImportError:
from tahu.python.core.sparkplug_b_pb2 import Payload

from mqtt_if import MQTTInterface
from sp_topic import SPTopic
Expand Down
12 changes: 9 additions & 3 deletions shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@

import cmd2

import sparkplug_b_pb2
from sparkplug_b import MetricDataType, addMetric, addNullMetric, initDatasetMetric
try:
from sparkplug_b_pb2 import Payload
from sparkplug_b import MetricDataType, addMetric
from sparkplug_b import addNullMetric, initDatasetMetric
except ImportError:
from tahu.python.core.sparkplug_b_pb2 import Payload
from tahu.python.core.sparkplug_b import MetricDataType, addMetric
from tahu.python.core.sparkplug_b import addNullMetric, initDatasetMetric

import sp_helpers
from sp_helpers import MsgType
Expand Down Expand Up @@ -433,7 +439,7 @@ def do_send(self, args):

msg_type = MsgType.CMD if args.msg_type == "CMD" else MsgType.DATA
topic = sp_dev.get_msg_topic(msg_type)
payload = sparkplug_b_pb2.Payload()
payload = Payload()
new_metric = True
while new_metric:
metric = self.choose_metric(sp_dev)
Expand Down
5 changes: 4 additions & 1 deletion sp_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
from typing import Optional
from enum import Enum

from sparkplug_b import MetricDataType
try:
from sparkplug_b import MetricDataType
except ImportError:
from tahu.python.core.sparkplug_b import MetricDataType


# Sparkplug namespace used
Expand Down