2016-12-04 08:37:01 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2017-04-02 08:31:23 +02:00
|
|
|
import os
|
2016-12-04 08:37:01 +01:00
|
|
|
import sys
|
2017-04-02 08:31:23 +02:00
|
|
|
import logging
|
2016-12-08 11:31:20 +01:00
|
|
|
import bumblebee.theme
|
2016-12-04 08:37:01 +01:00
|
|
|
import bumblebee.engine
|
|
|
|
import bumblebee.config
|
2016-12-04 16:14:43 +01:00
|
|
|
import bumblebee.output
|
2016-12-09 19:29:16 +01:00
|
|
|
import bumblebee.input
|
2017-04-02 08:56:44 +02:00
|
|
|
import bumblebee.modules.error
|
2016-12-04 08:37:01 +01:00
|
|
|
|
|
|
|
def main():
|
|
|
|
config = bumblebee.config.Config(sys.argv[1:])
|
2017-04-04 15:15:50 +02:00
|
|
|
|
|
|
|
if config.debug():
|
|
|
|
logging.basicConfig(
|
|
|
|
level=logging.DEBUG,
|
|
|
|
format="[%(asctime)s] %(levelname)-8s %(message)s",
|
|
|
|
filename=os.path.expanduser(config.logfile())
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
logging.basicConfig(
|
|
|
|
level=logging.DEBUG,
|
|
|
|
format="[%(asctime)s] %(levelname)-8s %(message)s",
|
|
|
|
stream=sys.stderr
|
|
|
|
)
|
|
|
|
|
2016-12-08 11:31:20 +01:00
|
|
|
theme = bumblebee.theme.Theme(config.theme())
|
|
|
|
output = bumblebee.output.I3BarOutput(theme=theme)
|
2016-12-09 19:29:16 +01:00
|
|
|
inp = bumblebee.input.I3BarInput()
|
2017-04-02 08:31:23 +02:00
|
|
|
engine = None
|
2016-12-04 08:37:01 +01:00
|
|
|
|
2017-04-02 08:31:23 +02:00
|
|
|
try:
|
|
|
|
engine = bumblebee.engine.Engine(
|
|
|
|
config=config,
|
|
|
|
output=output,
|
|
|
|
inp=inp,
|
|
|
|
)
|
|
|
|
engine.run()
|
2017-05-13 20:28:11 +02:00
|
|
|
except KeyboardInterrupt as error:
|
|
|
|
inp.stop()
|
|
|
|
sys.exit(0)
|
2017-04-02 08:31:23 +02:00
|
|
|
except BaseException as e:
|
2017-06-16 15:36:56 +02:00
|
|
|
if not engine: raise
|
2017-06-10 14:08:49 +02:00
|
|
|
module = engine.current_module()
|
2017-04-02 08:31:23 +02:00
|
|
|
logging.exception(e)
|
|
|
|
if output.started():
|
|
|
|
output.flush()
|
|
|
|
output.end()
|
|
|
|
else:
|
|
|
|
output.start()
|
|
|
|
import time
|
|
|
|
while True:
|
|
|
|
output.begin()
|
|
|
|
error = bumblebee.modules.error.Module(engine, config)
|
2017-06-10 14:08:49 +02:00
|
|
|
error.set("exception occurred: {} in {}".format(e, module))
|
2017-04-02 08:31:23 +02:00
|
|
|
widget = error.widgets()[0]
|
|
|
|
widget.link_module(error)
|
|
|
|
output.draw(widget, error)
|
|
|
|
output.flush()
|
|
|
|
output.end()
|
|
|
|
time.sleep(1)
|
2016-12-09 19:29:16 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
2016-12-04 08:37:01 +01:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|