Commit b0b010cd authored by Marius Kriegerowski's avatar Marius Kriegerowski
Browse files

Fixed entrypoint and improved verbosity selector

parent e02aff7c
Pipeline #27770 passed with stage
in 1 minute and 27 seconds
......@@ -24,23 +24,23 @@ import argparse
from rabotnik import Rabotnik, Assembly
from rabotnik.bus import MessageBus
from rules import GetBuilding # pylint: disable=import-error
from rules import GetFloorspace # pylint: disable=import-error
from rules import GetBuildingLandUse # pylint: disable=import-error
from rules import GetPointsInBuilding # pylint: disable=import-error
from .rules import GetBuilding
from .rules import GetFloorspace
from .rules import GetBuildingLandUse
from .rules import GetPointsInBuilding
rabotnik_logger = logging.getLogger("rabotnik")
rabotnik_logger.setLevel(logging.DEBUG)
rabotnik_logger.addHandler(logging.StreamHandler(sys.stdout))
logger = logging.getLogger("rabotnikobm")
logger = logging.getLogger(__name__)
# Initiate the rabotnik
rabotnik = Rabotnik("rabotnik-obm")
async def main():
async def start_rabotnik_obm():
# Initiate the message bus
message_bus = MessageBus()
......@@ -68,25 +68,33 @@ async def main():
await message_bus.subscribe("building", rules.run)
if __name__ == "__main__":
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", help="verbose mode", action="store_true")
parser.add_argument(
"-v",
"--verbosity",
action="count",
default=0,
help="increase output verbosity (e.g., -vv is more than -v)",
)
args = parser.parse_args()
if args.verbose:
log_level = logging.DEBUG
else:
log_level = logging.INFO
default_log_level = logging.WARNING
log_level = default_log_level - (args.verbosity * 10)
logger.setLevel(log_level)
logging.basicConfig(level=log_level)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
stream_handler = logging.StreamHandler(sys.stdout)
stream_handler.setFormatter(formatter)
logger.addHandler(stream_handler)
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.create_task(start_rabotnik_obm())
loop.run_forever()
if __name__ == "__main__":
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment