From d443df6cb43a527b8aee45f2127c44981b048c7c Mon Sep 17 00:00:00 2001 From: Stephen Gran Date: Sun, 2 Feb 2014 09:27:12 +0000 Subject: [PATCH] use json marshalling Signed-off-by: Stephen Gran --- ud-replicated | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ud-replicated b/ud-replicated index 1efbcea..8bef0a5 100755 --- a/ud-replicated +++ b/ud-replicated @@ -25,6 +25,7 @@ from dsa_mq.connection import Connection from dsa_mq.config import Config +import json import logging import logging.handlers import optparse @@ -77,6 +78,10 @@ def do_replicate(message): global last_run last_update = int(time.time()) timestamp = last_update + try: + message = json.loads(message) + except ValueError: + pass if isinstance(message, dict): timestamp = message.get('timestamp', last_update) @@ -120,7 +125,7 @@ def main(): sys.exit(0) if __name__ == '__main__': - do_replicate( + do_replicate(json.dumps( {'timestamp': time.time(), - 'message': 'startup complete'}) + 'message': 'startup complete'})) main() -- 2.20.1