test_samsat_info.py
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import sys
import os
from optparse import OptionParser
import locale
import importlib
import imp
from opensipkd.forwarder.iso8583_forwarder import conf
from opensipkd.forwarder.modules.ws_tools import send_rpc
def main(argv=sys.argv):
# global listen_ports
# global ip_conf
# global allowed_ips
# global hosts
# global logs
# global stop_dir
# global running
# global log
##############
# Blok Utama #
##############
global conf
conf_file = os.path.join('conf', 'forwarder.py')
host_name = 'bjb'
log_dir = 'logs'
method = 'get_tagihan'
host = 'bjb'
pars = OptionParser()
pars.add_option('-p', '--no-pol')
pars.add_option('-c', '--conf-file', default=conf_file, help='default ' + conf_file)
pars.add_option('-o', '--host', default=host, help='default ' + host)
pars.add_option('-m', '--method', default=method, help='default ' + method)
option, remain = pars.parse_args(argv[1:])
conf_file = os.path.realpath(option.conf_file)
conf = imp.load_source('conf', conf_file)
rpc = conf.rpc
method = option.method
host = option.host
no_pol = option.no_pol
message = dict(kd_bank=conf.host[host]['id'],
kd_biller=rpc['kd_biller'],
kd_channel='6010',
kd_produk=rpc['kd_produk']
)
if method=='get_tagihan':
message.update(dict(no_polisi=no_pol))
print(message)
rpc = conf.rpc
rows = send_rpc(rpc['user'], rpc['key'], rpc['url'], method, message)
print rows