#!@PYTHON@
+import asyncio
import sys
-import tornado.ioloop
import tornado.options
import ipfire
-class TaskRunner(object):
- def __init__(self, *args, **kwargs):
- self.backend = ipfire.Backend(*args, **kwargs)
-
- # Create an IOLoop
- self.ioloop = tornado.ioloop.IOLoop.current()
-
- def run_task(self, name, *args, **kwargs):
- """
- This method runs the task with the given name and
- arguments asynchronically and exits the program in
- case on a non-zero exit code
- """
- async def task():
- await self.backend.run_task(name, *args, **kwargs)
-
- return self.ioloop.run_sync(task)
-
-
-def main():
- z = TaskRunner("@configsdir@/@PACKAGE_NAME@.conf")
+async def main():
+ backend = ipfire.Backend("@configsdir@/@PACKAGE_NAME@.conf")
if len(sys.argv) < 2:
sys.stderr.write("Argument needed\n")
args = tornado.options.parse_command_line()
# Run the task
- z.run_task(*args)
+ await backend.run_task(*args)
-main()
+asyncio.run(main())