Skip to content
Permalink
Browse files

Update gmail: Add topic and topic action params.

Signed-off-by: Bofu Chen (bafu) <bofu@dt42.io>
  • Loading branch information...
bafu committed Jul 22, 2019
1 parent 23d3d0f commit 226e737499f7614fb9c24e41fc89611f0accccdd
Showing with 15 additions and 2 deletions.
  1. +15 −2 berrynet/client/gmail.py
@@ -99,8 +99,6 @@ def __init__(self, comm_config):
self.comm_config = comm_config
for topic, functor in self.comm_config['subscribe'].items():
self.comm_config['subscribe'][topic] = eval(functor)
self.comm_config['subscribe']['berrynet/engine/darknet/result'] = self.update
self.comm_config['subscribe']['berrynet/engine/tensorflow/result'] = self.update
self.comm = Communicator(self.comm_config, debug=True)
self.email = comm_config['email']
self.pipeline_compatible = comm_config['pipeline_compatible']
@@ -193,6 +191,17 @@ def parse_args():
type=int,
help='MQTT broker port.'
)
ap.add_argument(
'--topic',
nargs='*',
default=['berrynet/engine/tflitedetector/result'],
help='The topic to listen, and can be indicated multiple times.'
)
ap.add_argument(
'--topic-action',
default='self.update',
help='The action for the indicated topics.'
)
ap.add_argument(
'--topic-config',
default=None,
@@ -221,11 +230,15 @@ def main():
else:
logger.setLevel(logging.INFO)

# Topics and actions can come from two sources: CLI and config file.
# Setup topic_config by parsing values from the two sources.
if args['topic_config']:
with open(args['topic_config']) as f:
topic_config = json.load(f)
else:
topic_config = {}
topic_config.update({t:args['topic_action'] for t in args['topic']})

comm_config = {
'subscribe': topic_config,
'broker': {

0 comments on commit 226e737

Please sign in to comment.
You can’t perform that action at this time.