<commit_before>#!/usr/bin/python3
import sys
import json
import datetime
import time
import urllib.request
import urllib.parse
import urllib.error

MP_URL = 'http://192.168.22.102:8000/markerstorage/markerdata/0/'
#MP_URL = 'http://192.168.22.30/osmproj1/markerstorage/markerdata/0/'
MP_POST_PASS = '<PASSWORD>'


def put_markerobject():
    _seq = 0

    payload = {'id': _seq,
               'create_dt':  datetime.datetime.now().isoformat(),
               'update_dt':  datetime.datetime.now().isoformat(),
               'name': 'object_test',
               'x': '142.370',
               'y': '43.765',
               'auther': 'dictoss',
               'desc': 'test messge'}

    try:
        query_args = {'password': <PASSWORD>POST_<PASSWORD>}
        encode_url_param = urllib.parse.urlencode(query_args)

        req = urllib.request.Request('%s?%s' % (MP_URL, encode_url_param))
        req.add_header('Content-Type', 'application/json; charset=utf-8')
        req.method = 'POST'
        req.data = json.dumps(payload).encode()

        r = urllib.request.urlopen(req)
        print('send PUT request.')
        print(('status code: %s' % (r.code)))
    except:
        print(('EXCEPT: fail PUT (%s)' % sys.exc_info()[1]))

    return


def main():
    put_markerobject()
    return 0


if __name__ == '__main__':
    ret = main()
    sys.exit(ret)<commit_msg>change http library to requests. - adjust same code python2 and python3.<commit_after>#!/usr/bin/env python
import sys
import json
import datetime
import time
import requests

MP_URL = 'http://192.168.22.102:8000/markerstorage/markerdata/0/'
#MP_URL = 'http://192.168.22.30/osmproj1/markerstorage/markerdata/0/'
MP_POST_PASS = '<PASSWORD>'


def put_markerobject():
    _seq = 0

    payload = {'id': _seq,
               'create_dt':  datetime.datetime.now().isoformat(),
               'update_dt':  datetime.datetime.now().isoformat(),
               'name': 'object_test',
               'x': '142.370',
               'y': '43.765',
               'auther': 'dictoss',
               'desc': 'test messge'}

    try:
        query_args = {'password': <PASSWORD>}
        header_args = {'Content-Type': 'application/json; charset=utf-8'}

        print('try send PUT request.')
        r = requests.post(MP_URL,
                          params=query_args,
                          headers=header_args,
                          data=json.dumps(payload).encode())

        print(('status code: %s' % (r.status_code)))
        print(r.text)
    except:
        print(('EXCEPT: fail PUT (%s)' % sys.exc_info()[1]))

    return


def main():
    put_markerobject()
    return 0


if __name__ == '__main__':
    ret = main()
    sys.exit(ret)
{'fraction_non_alphanumeric': 0.15415746872700514, 'fraction_numerical': 0.032744665194996324, 'mean_word_length': 2.299757281553398, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6917904', 'n_tokens_mistral': 949, 'n_tokens_neox': 873, 'n_words': 176}