Commit 4388594a by Owo Sugiana

web-client.py tambah --conf

1 parent 4d7044d2
......@@ -5,3 +5,4 @@ __pycache__
test-*
test.ini
dist
build
0.1.6 2020-04-09
----------------
- web-client.py tambah --conf untuk ISO8583 multi.
0.1.5 2020-04-28
----------------
- read_conf.py tidak lagi mewajibkan setiap modul punya init()
......
......@@ -7,7 +7,7 @@ from time import (
time,
)
from threading import Thread
from optparse import OptionParser
from argparse import ArgumentParser
headers = {'content-type': 'application/json'}
......@@ -71,19 +71,21 @@ help_amount = 'dibutuhkan saat --method payment dan reversal'
help_ntb = 'dibutuhkan saat --method payment dan reversal'
help_stan = 'dibutuhkan saat --method payment dan reversal'
help_bit = 'bit tambahan, contoh: --bit=42:TOKOPEDIA'
parser = OptionParser()
parser.add_option('', '--url', default=default_url, help=help_url)
parser.add_option('', '--host', default=default_host, help=help_host)
parser.add_option(
'-c', '--count', type='int', default=default_count, help=help_count)
parser.add_option('', '--method', default=default_method, help=help_method)
parser.add_option('', '--invoice-id', help=help_invoice_id)
parser.add_option('', '--amount', type=int, help=help_amount)
parser.add_option('', '--ntb', help=help_ntb)
parser.add_option('', '--stan', help=help_stan)
parser.add_option('', '--bit', help=help_bit)
option, args = parser.parse_args(sys.argv[1:])
help_conf = 'konfigurasi tambahan, contoh untuk multi: --conf=pajak:bphtb'
parser = ArgumentParser()
parser.add_argument('--url', default=default_url, help=help_url)
parser.add_argument('--host', default=default_host, help=help_host)
parser.add_argument(
'--count', type=int, default=default_count, help=help_count)
parser.add_argument('--method', default=default_method, help=help_method)
parser.add_argument('--invoice-id', help=help_invoice_id)
parser.add_argument('--amount', type=int, help=help_amount)
parser.add_argument('--ntb', help=help_ntb)
parser.add_argument('--stan', help=help_stan)
parser.add_argument('--bit', help=help_bit)
parser.add_argument('--conf', help=help_conf)
option = parser.parse_args(sys.argv[1:])
url = option.url
count = option.count
......@@ -93,7 +95,7 @@ if option.method != 'echo':
if option.method in ('payment', 'reversal'):
required('amount')
if option.method == 'payment':
required('ntb', datetime.now().strftime('%Y%m%d%H%m%s'))
required('ntb', datetime.now().strftime('%y%m%d%H%m%s'))
required('stan', datetime.now().strftime('%H%M%S'))
else:
required('ntb')
......@@ -104,6 +106,12 @@ if option.method != 'echo':
bit, value = t.split(':')
bits[bit] = value
p['bits'] = bits
if option.conf:
conf = dict()
for t in option.conf.split(','):
key, val = t.split(':')
conf[key] = val
p['conf'] = conf
data = dict(method=option.method, params=[p], jsonrpc='2.0')
for i in range(count):
......
......@@ -116,9 +116,6 @@ class CommonConnection(Log):
self.log_info('Receive {}'.format([raw]))
def log_send(self, raw):
if isinstance(raw, bytes):
raw = raw.decode('utf-8')
raw = to_str(raw)
self.log_info('Send {}'.format([raw]))
def log_close(self, reason):
......@@ -626,7 +623,7 @@ def check_job():
raw = iso.getRawIso()
with_header = connection.raw_for_send(raw)
with_headers.append(with_header)
raw = ''.join(with_headers)
raw = b''.join(with_headers)
connection.just_send(raw)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!