From: Stephen Gran Date: Sun, 2 Feb 2014 09:27:12 +0000 (+0000) Subject: use json marshalling X-Git-Tag: userdir-ldap-0.3.85~16 X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap.git;a=commitdiff_plain;h=d443df6cb43a527b8aee45f2127c44981b048c7c use json marshalling Signed-off-by: Stephen Gran --- 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()