test_payment.py
1.81 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# import sys
# import os
# sys.path.insert(0, 'modules')
# module_name = sys.argv[1]
# name = module_name + '.test_payment'
# module = __import__(name)
# sub_module = getattr(module, 'test_payment')
# sub_module.main(sys.argv[2:])
import sys
import os
from optparse import OptionParser
import locale
from ..read_conf import (read_conf, get_str, name_conf)
import logging
from pyramid.paster import setup_logging
from .forwarder import get_db
# import importlib
# import imp
# from .iso8583_forwarder import conf
from .forwarder import logs
try:
from configparser import (
ConfigParser,
NoOptionError,
)
except ImportError:
from ConfigParser import (
ConfigParser,
NoOptionError,
)
def main(argv=sys.argv):
##############
# Blok Utama #
##############
conf_file = "" # os.path.join('conf', 'forwarder.py')
host_name = 'bjb'
log_dir = 'logs'
pars = OptionParser()
pars.add_option('-c', '--conf-file', default=conf_file, help='default ' + conf_file)
pars.add_option('-o', '--host', default=host_name, help='default ' + host_name)
pars.add_option('-i', '--invoice-id')
pars.add_option('-b', '--bank-id', default='001', help='default Bank Indonesia')
option, remain = pars.parse_args(argv[1:])
conf_file = os.path.realpath(option.conf_file)
conf = read_conf(conf_file)
get_db(conf)
setup_logging(conf_file)
log = logging.getLogger(__file__)
logs.append(log)
conf = ConfigParser()
conf.read(conf_file)
localization = get_str(conf, 'app:main', 'localization', default='id_ID.UTF-8')
locale.setlocale(locale.LC_ALL, localization)
module_name = 'main'
name = name_conf[host_name]['module'] + '.test_payment'
module = __import__(name, fromlist=[module_name])
print(name)
module.main(argv[2:])