Import broker backend by name

kivy_mainline_and_py3.8
Tyler Goodlet 2018-01-25 21:08:49 -05:00
parent c6cff5a432
commit 4e1c64a7fb
1 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,7 @@
""" """
Console interface to broker client/daemons. Console interface to broker client/daemons.
""" """
import importlib
from pprint import pformat from pprint import pformat
import click import click
import trio import trio
@ -22,8 +23,8 @@ def run(loglevel, main):
@click.command() @click.command()
@click.option('--broker', default='questrade', help='Broker backend to use') @click.option('--broker', default='questrade', help='Broker backend to use')
@click.option('--loglevel', '-l', default='warning', help='Logging level') @click.option('--loglevel', '-l', default='info', help='Logging level')
def pikerd(broker, loglevel): def pikerd(broker, loglevel):
# import broker module daemon entry point # import broker module daemon entry point
from .questrade import serve_forever brokermod = importlib.import_module('.' + broker, 'piker.brokers')
run(loglevel, serve_forever) run(loglevel, brokermod.serve_forever)