test_samsat_info.py 1.54 KB
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