# Importing section
import json
import requests
import argparse
import hashlib
import time

from http import HTTPStatus

#  Main
if __name__ == "__main__":
    arg_parser = argparse.ArgumentParser()
    args = arg_parser.parse_args()

    set_cmd = 'updateSla'
    params = {
                'idx': 'sla04',
                'start': 3000,
                'end': 3900
             }

    cmd_url = 'http://localhost:9119/%s' % set_cmd

    headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

    print('COMMAND: %s' % cmd_url)
    print('PARAMS: %s' % params)

    r = requests.post(cmd_url, headers=headers, json=params)
    data = json.loads(r.text)
    print('RESPONSE: %s\n' % data)

    # Wait some seconds to be sure that the transaction has been handled
    time.sleep(5)

    check_tx_url = 'http://localhost:9119/checkTx/%s' % data['tx_hash']
    print('CHECK TX: %s' % check_tx_url)
    r = requests.get(check_tx_url)

    data = json.loads(r.text)
    print('RESPONSE: %s\n' % data)

[((12, 17, 12, 42), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ({}, {}), '()', False, 'import argparse\n'), ((29, 8, 29, 60), 'requests.post', 'requests.post', (), '', False, 'import requests\n'), ((30, 11, 30, 29), 'json.loads', 'json.loads', ({(30, 22, 30, 28): 'r.text'}, {}), '(r.text)', False, 'import json\n'), ((34, 4, 34, 17), 'time.sleep', 'time.sleep', ({(34, 15, 34, 16): '(5)'}, {}), '(5)', False, 'import time\n'), ((38, 8, 38, 34), 'requests.get', 'requests.get', ({(38, 21, 38, 33): 'check_tx_url'}, {}), '(check_tx_url)', False, 'import requests\n'), ((40, 11, 40, 29), 'json.loads', 'json.loads', ({(40, 22, 40, 28): 'r.text'}, {}), '(r.text)', False, 'import json\n')]