# 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, 'argparse.ArgumentParser', 'argparse.ArgumentParser', False, 'import argparse\n'), (29, 'requests.post', 'requests.post', False, 'import requests\n'), (30, 'json.loads', 'json.loads', False, 'import json\n'), (34, 'time.sleep', 'time.sleep', False, 'import time\n'), (38, 'requests.get', 'requests.get', False, 'import requests\n'), (40, 'json.loads', 'json.loads', False, 'import json\n')]