# 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)

[((173, 198), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (196, 198), False, 'import argparse\n'), ((594, 646), 'requests.post', 'requests.post', (['cmd_url'], {'headers': 'headers', 'json': 'params'}), '(cmd_url, headers=headers, json=params)\n', (607, 646), False, 'import requests\n'), ((658, 676), 'json.loads', 'json.loads', (['r.text'], {}), '(r.text)\n', (668, 676), False, 'import json\n'), ((790, 803), 'time.sleep', 'time.sleep', (['(5)'], {}), '(5)\n', (800, 803), False, 'import time\n'), ((926, 952), 'requests.get', 'requests.get', (['check_tx_url'], {}), '(check_tx_url)\n', (938, 952), False, 'import requests\n'), ((965, 983), 'json.loads', 'json.loads', (['r.text'], {}), '(r.text)\n', (975, 983), False, 'import json\n')]