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()
|
|
|
|
except BaseException as e:
|
|
|
|
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)
|
|
|
|
error.set("exception occurred: {}".format(e))
|
|
|
|
widget = error.widgets()[0]
|
|
|
|
widget.link_module(error)
|
|
|
|
output.draw(widget, error)
|
|
|
|
output.flush()
|
|
|
|
output.end()
|
|
|
|
time.sleep(1)
|
2016-12-10 08:09:13 +01:00
|
|
|
# try:
|
|
|
|
# except KeyboardInterrupt as error:
|
|
|
|
# inp.stop()
|
|
|
|
# sys.exit(0)
|
|
|
|
# except bumblebee.error.BaseError as error:
|
|
|
|
# inp.stop()
|
|
|
|
# sys.stderr.write("fatal: {}\n".format(error))
|
|
|
|
# sys.exit(1)
|
|
|
|
# except Exception as error:
|
|
|
|
# inp.stop()
|
|
|
|
# sys.stderr.write("fatal: {}\n".format(error))
|
|
|
|
# sys.exit(2)
|
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
|