From 47a72b57d6cc28bd8a3e5504420fcf79b061698b Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Sun, 7 Feb 2021 03:01:57 +0100 Subject: [PATCH] Improved error handling 2 --- igmirror.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/igmirror.py b/igmirror.py index 2d90323..5bb604b 100644 --- a/igmirror.py +++ b/igmirror.py @@ -10,7 +10,11 @@ import re def add_igaccount(acc_id): accfile = './db/accounts/{}'.format(acc_id) - if not os.path.exists(accfile) and os.path.exists('./scripts/user_create'): + if not os.path.exists('./scripts/user_create'): + print('E| You may need to initialize the server environment first') + return 1 + + if not os.path.exists(accfile): data = getig_user_data(acc_id) name = data['graphql']['user']['full_name'] name = re.sub(r'[^a-zA-Z0-9_\s]', '', name) @@ -25,7 +29,8 @@ def add_igaccount(acc_id): w.write(json.dumps(account)) w.close() else: - print('E| You may need to initialize the server environment first') + print('W| User "{}" already exists in local database'.format(acc_id)) + return 0 def random_string(count=32): return ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k=count))