Refactors handling import of users.

This commit is contained in:
PhilipWafula 2021-05-03 11:36:19 +03:00
parent 0d57fb8679
commit 32e08dfddf
Signed by untrusted user: mango-habanero
GPG Key ID: B00CE9034DA19FB7

View File

@ -87,6 +87,13 @@ chain_str = str(chain_spec)
batch_size = args.batch_size
batch_delay = args.batch_delay
db_configs = {
'database': config.get('DATABASE_NAME'),
'host': config.get('DATABASE_HOST'),
'port': config.get('DATABASE_PORT'),
'user': config.get('DATABASE_USER'),
'password': config.get('DATABASE_PASSWORD')
}
def build_ussd_request(phone, host, port, service_code, username, password, ssl=False):
@ -135,6 +142,9 @@ if __name__ == '__main__':
for y in x[2]:
if y[len(y)-5:] != '.json':
continue
# handle json containing person object
filepath = None
if y != 'ussd_data.json':
filepath = os.path.join(x[0], y)
f = open(filepath, 'r')
try:
@ -178,7 +188,8 @@ if __name__ == '__main__':
s_meta.link(s_balance)
s_phone.link(s_meta)
s_phone.apply_async(countdown=7) # block time plus a bit of time for ussd processing
# block time plus a bit of time for ussd processing
s_phone.apply_async(countdown=7)
i += 1
sys.stdout.write('imported {} {}'.format(i, u).ljust(200) + "\r")
@ -188,4 +199,3 @@ if __name__ == '__main__':
time.sleep(batch_delay)
j = 0
#fi.close()