diff --git a/bumblebee-status b/bumblebee-status old mode 100644 new mode 100755 index e69de29..b048a61 --- a/bumblebee-status +++ b/bumblebee-status @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import sys +import bumblebee.engine +import bumblebee.config + +def main(): + config = bumblebee.config.Config(sys.argv[1:]) + engine = bumblebee.engine.Engine( + config=config + ) + + engine.run() + +if __name__ == "__main__": + main() + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/bumblebee/engine.py b/bumblebee/engine.py new file mode 100644 index 0000000..f9996b6 --- /dev/null +++ b/bumblebee/engine.py @@ -0,0 +1,25 @@ +"""Core application engine""" + +class Engine(object): + """Engine for driving the application + + This class connects input/output, instantiates all + required modules and drives the "event loop" + """ + def __init__(self, config): + self._running = True + + def running(self): + """Check whether the event loop is running""" + return self._running + + def stop(self): + """Stop the event loop""" + self._running = False + + def run(self): + """Start the event loop""" + while self.running(): + pass + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/tests/test_engine.py b/tests/test_engine.py new file mode 100644 index 0000000..0d81578 --- /dev/null +++ b/tests/test_engine.py @@ -0,0 +1,13 @@ +# pylint: disable=C0103,C0111 +import unittest + +from bumblebee.engine import Engine + +class TestEngine(unittest.TestCase): + def setUp(self): + self.engine = Engine(None) + + def test_stop(self): + self.assertTrue(self.engine.running()) + self.engine.stop() + self.assertFalse(self.engine.running())