Skip to content

Commit fcc055a

Browse files
author
joerggollnick
committed
args are optional
1 parent 2ec2404 commit fcc055a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

mqttwarn/services/mqtt_filter.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ def plugin(srv, item):
1515
srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__, item.service, item.target)
1616

1717
# same as for ssh
18-
args=json.loads(item.message)["args"]
18+
json_message=json.loads(item.message)
1919

20-
if type(args) is list and len(args) == 1:
21-
args=args[0]
20+
args = None
21+
if json_message is not None:
22+
args = json_message["args"]
2223

23-
if type(args) is list:
24-
args=tuple([ quote(v) for v in args ]) #escape the shell args
25-
elif type(args) is str or type(args) is unicode:
26-
args=(quote(args),)
24+
if type(args) is list and len(args) == 1:
25+
args=args[0]
26+
27+
if type(args) is list:
28+
args=tuple([ quote(v) for v in args ]) #escape the shell args
29+
elif type(args) is str or type(args) is unicode:
30+
args=(quote(args),)
2731

2832
# parse topic
2933
topic=list(map( lambda x: quote(x), item.topic.split('/') ))

0 commit comments

Comments
 (0)