Improved error handling
This commit is contained in:
parent
ece785b02e
commit
d11a739593
16
igmirror.py
16
igmirror.py
|
@ -10,7 +10,7 @@ import re
|
||||||
|
|
||||||
def add_igaccount(acc_id):
|
def add_igaccount(acc_id):
|
||||||
accfile = './db/accounts/{}'.format(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)
|
data = getig_user_data(acc_id)
|
||||||
name = data['graphql']['user']['full_name']
|
name = data['graphql']['user']['full_name']
|
||||||
name = re.sub(r'[^a-zA-Z0-9_\s]', '', name)
|
name = re.sub(r'[^a-zA-Z0-9_\s]', '', name)
|
||||||
|
@ -19,13 +19,13 @@ def add_igaccount(acc_id):
|
||||||
'username': acc_id,
|
'username': acc_id,
|
||||||
'password': random_string()
|
'password': random_string()
|
||||||
}
|
}
|
||||||
if os.path.exists('./scripts/user_create'):
|
os.system('./scripts/user_create \'{}\' \'{}\' \'{}\''.format(\
|
||||||
os.system('./scripts/user_create \'{}\' \'{}\' \'{}\''.format(\
|
account['name'], account['username'], account['password']))
|
||||||
account['name'], account['username'], account['password']))
|
w = open(accfile, 'w')
|
||||||
w = open(accfile, 'w')
|
w.write(json.dumps(account))
|
||||||
w.write(json.dumps(account))
|
w.close()
|
||||||
w.close()
|
else:
|
||||||
#data = getig_user_data(acc_id)
|
print('E| You may need to initialize the server environment first')
|
||||||
|
|
||||||
def random_string(count=32):
|
def random_string(count=32):
|
||||||
return ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k=count))
|
return ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k=count))
|
||||||
|
|
Loading…
Reference in New Issue