From d11a739593b823b7537a21c40f51f6c2bf97d09f Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Sun, 7 Feb 2021 02:59:14 +0100 Subject: [PATCH] Improved error handling --- igmirror.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/igmirror.py b/igmirror.py index 160b4a5..2d90323 100644 --- a/igmirror.py +++ b/igmirror.py @@ -10,7 +10,7 @@ import re def add_igaccount(acc_id): accfile = './db/accounts/{}'.format(acc_id) - if not os.path.exists(accfile): + if not os.path.exists(accfile) and os.path.exists('./scripts/user_create'): data = getig_user_data(acc_id) name = data['graphql']['user']['full_name'] name = re.sub(r'[^a-zA-Z0-9_\s]', '', name) @@ -19,13 +19,13 @@ def add_igaccount(acc_id): 'username': acc_id, 'password': random_string() } - if os.path.exists('./scripts/user_create'): - os.system('./scripts/user_create \'{}\' \'{}\' \'{}\''.format(\ - account['name'], account['username'], account['password'])) - w = open(accfile, 'w') - w.write(json.dumps(account)) - w.close() - #data = getig_user_data(acc_id) + os.system('./scripts/user_create \'{}\' \'{}\' \'{}\''.format(\ + account['name'], account['username'], account['password'])) + w = open(accfile, 'w') + w.write(json.dumps(account)) + w.close() + else: + print('E| You may need to initialize the server environment first') def random_string(count=32): return ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k=count))