1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
From 22062d99a89922e02b626e4701feaac8947af5fb Mon Sep 17 00:00:00 2001
From: Scott Murray <scott.murray@konsulko.com>
Date: Fri, 7 Oct 2022 15:54:48 -0400
Subject: [PATCH 1/2] dbc2val: add installation mechanism
Add setup.py and setup.cfg to allow installing the dbc2val module
and dbcfeeder.py in a way suitable for packaging. Some of the
imports in the scripts have been tweaked to enable running against
an installed copy of dbc2val.
Upstream-Status: pending
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
dbc2val/__init__.py | 0
dbc2val/databroker.py | 4 +--
dbc2val/dbc2vssmapper.py | 12 +++----
dbc2val/dbcfeeder.py | 8 ++---
dbc2val/gen_proto/__init__.py | 0
dbc2val/gen_proto/sdv/__init__.py | 0
dbc2val/gen_proto/sdv/databroker/__init__.py | 0
.../gen_proto/sdv/databroker/v1/__init__.py | 0
.../gen_proto/sdv/databroker/v1/broker_pb2.py | 2 +-
.../sdv/databroker/v1/broker_pb2_grpc.py | 2 +-
.../sdv/databroker/v1/collector_pb2.py | 2 +-
.../sdv/databroker/v1/collector_pb2_grpc.py | 2 +-
setup.cfg | 31 ++++++++++++++++
setup.py | 36 +++++++++++++++++++
14 files changed, 82 insertions(+), 17 deletions(-)
create mode 100644 dbc2val/__init__.py
create mode 100644 dbc2val/gen_proto/__init__.py
create mode 100644 dbc2val/gen_proto/sdv/__init__.py
create mode 100644 dbc2val/gen_proto/sdv/databroker/__init__.py
create mode 100644 dbc2val/gen_proto/sdv/databroker/v1/__init__.py
create mode 100644 setup.cfg
create mode 100644 setup.py
diff --git a/dbc2val/__init__.py b/dbc2val/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dbc2val/databroker.py b/dbc2val/databroker.py
index c1a941a..ba52980 100644
--- a/dbc2val/databroker.py
+++ b/dbc2val/databroker.py
@@ -16,13 +16,13 @@
import logging
import grpc
-from gen_proto.sdv.databroker.v1 import (
+from dbc2val.gen_proto.sdv.databroker.v1 import (
broker_pb2,
broker_pb2_grpc,
collector_pb2,
collector_pb2_grpc,
)
-from gen_proto.sdv.databroker.v1 import types_pb2 as types # for export
+from dbc2val.gen_proto.sdv.databroker.v1 import types_pb2 as types # for export
log = logging.getLogger(__name__)
diff --git a/dbc2val/dbc2vssmapper.py b/dbc2val/dbc2vssmapper.py
index 05b78f1..d76c068 100644
--- a/dbc2val/dbc2vssmapper.py
+++ b/dbc2val/dbc2vssmapper.py
@@ -20,8 +20,8 @@
import yaml
-import transforms.mapping
-import transforms.math
+from dbc2val.transforms import mapping
+from dbc2val.transforms import math
import logging
log = logging.getLogger(__name__)
@@ -33,13 +33,13 @@ class mapper:
self.mapping = yaml.full_load(file)
self.transforms = {}
- self.transforms["fullmapping"] = transforms.mapping.mapping(
+ self.transforms["fullmapping"] = mapping.mapping(
discard_non_matching_items=True
)
- self.transforms["partialmapping"] = transforms.mapping.mapping(
+ self.transforms["partialmapping"] = mapping.mapping(
discard_non_matching_items=False
)
- self.transforms["math"] = transforms.math.math()
+ self.transforms["math"] = math.math()
for key in self.mapping.keys():
self.mapping[key]["lastupdate"] = 0.0
@@ -93,4 +93,4 @@ class mapper:
def __getitem__(self, item):
return self.mapping[item]
-
\ No newline at end of file
+
diff --git a/dbc2val/dbcfeeder.py b/dbc2val/dbcfeeder.py
index 5267369..7daaa2b 100755
--- a/dbc2val/dbcfeeder.py
+++ b/dbc2val/dbcfeeder.py
@@ -28,16 +28,13 @@ import sys
import time
from signal import SIGINT, SIGTERM, signal
-import canplayer
-import dbc2vssmapper
-import dbcreader
import grpc
-import j1939reader
+from dbc2val import dbc2vssmapper, dbcreader, j1939reader, canplayer
# kuksa related
from kuksa_viss_client import KuksaClientThread
# databroker related
-import databroker
+from dbc2val import databroker
# global variable for usecase, default databroker
USE_CASE = ""
@@ -289,6 +286,7 @@ def parse_config(filename):
"/etc/dbc_feeder.ini",
"config/dbc_feeder.ini",
]
+ configfile = None
for candidate in config_candidates:
if os.path.isfile(candidate):
configfile = candidate
diff --git a/dbc2val/gen_proto/__init__.py b/dbc2val/gen_proto/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dbc2val/gen_proto/sdv/__init__.py b/dbc2val/gen_proto/sdv/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dbc2val/gen_proto/sdv/databroker/__init__.py b/dbc2val/gen_proto/sdv/databroker/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dbc2val/gen_proto/sdv/databroker/v1/__init__.py b/dbc2val/gen_proto/sdv/databroker/v1/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dbc2val/gen_proto/sdv/databroker/v1/broker_pb2.py b/dbc2val/gen_proto/sdv/databroker/v1/broker_pb2.py
index 98dc94a..6deacfb 100644
--- a/dbc2val/gen_proto/sdv/databroker/v1/broker_pb2.py
+++ b/dbc2val/gen_proto/sdv/databroker/v1/broker_pb2.py
@@ -12,7 +12,7 @@ from google.protobuf import symbol_database as _symbol_database
_sym_db = _symbol_database.Default()
-from gen_proto.sdv.databroker.v1 import types_pb2 as sdv_dot_databroker_dot_v1_dot_types__pb2
+from dbc2val.gen_proto.sdv.databroker.v1 import types_pb2 as sdv_dot_databroker_dot_v1_dot_types__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1esdv/databroker/v1/broker.proto\x12\x11sdv.databroker.v1\x1a\x1dsdv/databroker/v1/types.proto\"*\n\x14GetDatapointsRequest\x12\x12\n\ndatapoints\x18\x01 \x03(\t\"\xb0\x01\n\x12GetDatapointsReply\x12I\n\ndatapoints\x18\x01 \x03(\x0b\x32\x35.sdv.databroker.v1.GetDatapointsReply.DatapointsEntry\x1aO\n\x0f\x44\x61tapointsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12+\n\x05value\x18\x02 \x01(\x0b\x32\x1c.sdv.databroker.v1.Datapoint:\x02\x38\x01\"!\n\x10SubscribeRequest\x12\r\n\x05query\x18\x02 \x01(\t\"\x9c\x01\n\x0eSubscribeReply\x12=\n\x06\x66ields\x18\x01 \x03(\x0b\x32-.sdv.databroker.v1.SubscribeReply.FieldsEntry\x1aK\n\x0b\x46ieldsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12+\n\x05value\x18\x02 \x01(\x0b\x32\x1c.sdv.databroker.v1.Datapoint:\x02\x38\x01\"#\n\x12GetMetadataRequest\x12\r\n\x05names\x18\x01 \x03(\t\"=\n\x10GetMetadataReply\x12)\n\x04list\x18\x01 \x03(\x0b\x32\x1b.sdv.databroker.v1.Metadata2\x9b\x02\n\x06\x42roker\x12_\n\rGetDatapoints\x12\'.sdv.databroker.v1.GetDatapointsRequest\x1a%.sdv.databroker.v1.GetDatapointsReply\x12U\n\tSubscribe\x12#.sdv.databroker.v1.SubscribeRequest\x1a!.sdv.databroker.v1.SubscribeReply0\x01\x12Y\n\x0bGetMetadata\x12%.sdv.databroker.v1.GetMetadataRequest\x1a#.sdv.databroker.v1.GetMetadataReplyb\x06proto3')
diff --git a/dbc2val/gen_proto/sdv/databroker/v1/broker_pb2_grpc.py b/dbc2val/gen_proto/sdv/databroker/v1/broker_pb2_grpc.py
index 5c87db1..bc6be8b 100644
--- a/dbc2val/gen_proto/sdv/databroker/v1/broker_pb2_grpc.py
+++ b/dbc2val/gen_proto/sdv/databroker/v1/broker_pb2_grpc.py
@@ -2,7 +2,7 @@
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
-from gen_proto.sdv.databroker.v1 import broker_pb2 as sdv_dot_databroker_dot_v1_dot_broker__pb2
+from dbc2val.gen_proto.sdv.databroker.v1 import broker_pb2 as sdv_dot_databroker_dot_v1_dot_broker__pb2
class BrokerStub(object):
diff --git a/dbc2val/gen_proto/sdv/databroker/v1/collector_pb2.py b/dbc2val/gen_proto/sdv/databroker/v1/collector_pb2.py
index 25d69dd..ea15409 100644
--- a/dbc2val/gen_proto/sdv/databroker/v1/collector_pb2.py
+++ b/dbc2val/gen_proto/sdv/databroker/v1/collector_pb2.py
@@ -12,7 +12,7 @@ from google.protobuf import symbol_database as _symbol_database
_sym_db = _symbol_database.Default()
-from gen_proto.sdv.databroker.v1 import types_pb2 as sdv_dot_databroker_dot_v1_dot_types__pb2
+from dbc2val.gen_proto.sdv.databroker.v1 import types_pb2 as sdv_dot_databroker_dot_v1_dot_types__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n!sdv/databroker/v1/collector.proto\x12\x11sdv.databroker.v1\x1a\x1dsdv/databroker/v1/types.proto\"\xba\x01\n\x17UpdateDatapointsRequest\x12N\n\ndatapoints\x18\x01 \x03(\x0b\x32:.sdv.databroker.v1.UpdateDatapointsRequest.DatapointsEntry\x1aO\n\x0f\x44\x61tapointsEntry\x12\x0b\n\x03key\x18\x01 \x01(\x05\x12+\n\x05value\x18\x02 \x01(\x0b\x32\x1c.sdv.databroker.v1.Datapoint:\x02\x38\x01\"\xaf\x01\n\x15UpdateDatapointsReply\x12\x44\n\x06\x65rrors\x18\x01 \x03(\x0b\x32\x34.sdv.databroker.v1.UpdateDatapointsReply.ErrorsEntry\x1aP\n\x0b\x45rrorsEntry\x12\x0b\n\x03key\x18\x01 \x01(\x05\x12\x30\n\x05value\x18\x02 \x01(\x0e\x32!.sdv.databroker.v1.DatapointError:\x02\x38\x01\"\xba\x01\n\x17StreamDatapointsRequest\x12N\n\ndatapoints\x18\x01 \x03(\x0b\x32:.sdv.databroker.v1.StreamDatapointsRequest.DatapointsEntry\x1aO\n\x0f\x44\x61tapointsEntry\x12\x0b\n\x03key\x18\x01 \x01(\x05\x12+\n\x05value\x18\x02 \x01(\x0b\x32\x1c.sdv.databroker.v1.Datapoint:\x02\x38\x01\"\xaf\x01\n\x15StreamDatapointsReply\x12\x44\n\x06\x65rrors\x18\x01 \x03(\x0b\x32\x34.sdv.databroker.v1.StreamDatapointsReply.ErrorsEntry\x1aP\n\x0b\x45rrorsEntry\x12\x0b\n\x03key\x18\x01 \x01(\x05\x12\x30\n\x05value\x18\x02 \x01(\x0e\x32!.sdv.databroker.v1.DatapointError:\x02\x38\x01\"R\n\x19RegisterDatapointsRequest\x12\x35\n\x04list\x18\x01 \x03(\x0b\x32\'.sdv.databroker.v1.RegistrationMetadata\"\x9d\x01\n\x14RegistrationMetadata\x12\x0c\n\x04name\x18\x01 \x01(\t\x12.\n\tdata_type\x18\x02 \x01(\x0e\x32\x1b.sdv.databroker.v1.DataType\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12\x32\n\x0b\x63hange_type\x18\x04 \x01(\x0e\x32\x1d.sdv.databroker.v1.ChangeType\"\x93\x01\n\x17RegisterDatapointsReply\x12H\n\x07results\x18\x01 \x03(\x0b\x32\x37.sdv.databroker.v1.RegisterDatapointsReply.ResultsEntry\x1a.\n\x0cResultsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x32\xd3\x02\n\tCollector\x12n\n\x12RegisterDatapoints\x12,.sdv.databroker.v1.RegisterDatapointsRequest\x1a*.sdv.databroker.v1.RegisterDatapointsReply\x12h\n\x10UpdateDatapoints\x12*.sdv.databroker.v1.UpdateDatapointsRequest\x1a(.sdv.databroker.v1.UpdateDatapointsReply\x12l\n\x10StreamDatapoints\x12*.sdv.databroker.v1.StreamDatapointsRequest\x1a(.sdv.databroker.v1.StreamDatapointsReply(\x01\x30\x01\x62\x06proto3')
diff --git a/dbc2val/gen_proto/sdv/databroker/v1/collector_pb2_grpc.py b/dbc2val/gen_proto/sdv/databroker/v1/collector_pb2_grpc.py
index 419bfde..2dee751 100644
--- a/dbc2val/gen_proto/sdv/databroker/v1/collector_pb2_grpc.py
+++ b/dbc2val/gen_proto/sdv/databroker/v1/collector_pb2_grpc.py
@@ -2,7 +2,7 @@
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
-from gen_proto.sdv.databroker.v1 import collector_pb2 as sdv_dot_databroker_dot_v1_dot_collector__pb2
+from dbc2val.gen_proto.sdv.databroker.v1 import collector_pb2 as sdv_dot_databroker_dot_v1_dot_collector__pb2
class CollectorStub(object):
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..70aab60
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,31 @@
+[metadata]
+name = dbc2val
+author = Sebastian Schildt, Naresh Nayak, Wenwen Chen
+author_email = sebastian.schildt@de.bosch.com, naresh.nayak@de.bosch.com, wenwen.chen@de.bosch.com
+description = kuksa.val DBC feeder
+long_description = file:README.md
+long_description_content_type = text/markdown
+url=https://github.com/eclipse/kuksa.val
+project_urls=
+ Source=https://github.com/eclipse/kuksa.val/tree/master/kuksa_feeders/dbc2val
+ Bug Tracker=https://github.com/eclipse/kuksa.val/issues
+classifiers =
+ Intended Audience :: Developers
+ Development Status :: 3 - Alpha
+ Environment :: Console
+ Programming Language :: Python :: 3
+ License :: OSI Approved :: Apache Software License
+ Operating System :: OS Independent
+ Topic :: Software Development
+
+license_file = LICENSE.txt
+
+[options]
+python_requires = >=3.6
+install_requires=
+ pyserial
+ pyyaml
+ kuksa-viss-client
+packages=find:
+include_package_data = True
+scripts=dbc2val/dbcfeeder.py
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..55951cc
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,36 @@
+# To avoid shipping dbcfeeder.py in the module itself, use the
+# technique outlined at:
+#
+# https://stackoverflow.com/a/50592100
+#
+# This can be removed if the directory structure is ever reorganized
+# more along the lines of upstream recommendations.
+#
+
+import fnmatch
+from setuptools import find_packages, setup
+from setuptools.command.build_py import build_py as build_py_orig
+
+exclude = ['dbc2val.dbcfeeder']
+
+class build_py(build_py_orig):
+ def find_package_modules(self, package, package_dir):
+ modules = super().find_package_modules(package, package_dir)
+ print("modules = %s" % modules)
+ return [(pkg, mod, file, ) for (pkg, mod, file, ) in modules
+ if not any(fnmatch.fnmatchcase(pkg + '.' + mod, pat=pattern)
+ for pattern in exclude)]
+
+setup(
+ version_config={
+ "template": "{tag}",
+ "dev_template": "{tag}-{ccount}",
+ "dirty_template": "{tag}-{ccount}-dirty",
+ "starting_version": "0.1.0",
+ "version_callback": None,
+ "version_file": None,
+ "count_commits_from_version_file": False
+ },
+ setup_requires=['setuptools-git-versioning'],
+ cmdclass={'build_py': build_py},
+)
--
2.37.3
|