From 87a5ab0b07857e274ce41f5306602c222b909226 Mon Sep 17 00:00:00 2001 From: Robin van Genderen Date: Mon, 22 Jul 2019 16:00:07 +0200 Subject: [PATCH] create empty prop if not exist --- manage_recipients/manage_recipients.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manage_recipients/manage_recipients.py b/manage_recipients/manage_recipients.py index 3f1b1df..e263f3f 100644 --- a/manage_recipients/manage_recipients.py +++ b/manage_recipients/manage_recipients.py @@ -33,11 +33,15 @@ def main(): try: webapp = user.store.prop(0X6773001F).value except NotFoundError: - print('Property PR_EC_RECIPIENT_HISTORY_JSON_W not found. User might have never used recipient history before.', file=sys.stderr) - sys.exit(1) + webapp = dict(recipients=[]) + webapp = json.loads(webapp) if options.backup: + if len(webapp['recipients']) == 0: + print('Property PR_EC_RECIPIENT_HISTORY_JSON_W not found . User might have never used recipient history before.', file=sys.stderr) + sys.exit(1) + f = open('%s.json' % user.name, 'w') f.write(json.dumps(webapp, sort_keys=True, indent=4, separators=(',', ': ')))