Source code for core.kernel
# core/kernel.py
#
#
""" CORE kernel module. """
__copyright__ = "Copyright 2015, B.H.J Thate"
## IMPORTS
from core.utils.opts import make_opts, opts_defs
from core.utils.other import hello, show_eggs
from core.cfg import cfg_kernel
from core.thing import Thing
from core.plugs import Plugs
from core.log import init
import logging
import time
import sys
import os
## PATH
[docs]def corepath():
for path in sys.path:
if "core" in path and "egg" in path: yield path
## KERNEL
[docs]class Kernel(Plugs):
[docs] def boot(zelf, *args, **kwargs):
zelf._start = time.time()
opts, arglist = make_opts(opts_defs)
cfg.update(cfg_kernel)
cfg.update(vars(opts))
for key,value in kwargs.items():
if not getattr(cfg , key, ""): cfg[key] = value
if not cfg.workdir: cfg.workdir = os.path.expanduser("~/core.data")
cfg.runargs = arglist
cfg.shell = True
if arglist: cfg.shell = False ; init("error")
else: init(cfg.loglevel, colors=cfg.colors)
if cfg.shell and args: hello(*args, **cfg)
if cfg.path:
for path in sys.path: print(path)
print()
plugs.boot(cfg.packages)
zelf.ready()
return zelf
[docs] def shutdown(zelf, *args, **kwargs):
logging.warn("# shutdown")
plugs.shutdown(cfg.packages)
## DEFINITIES
kernel = Kernel()
plugs = Plugs()
cfg = Thing()
fleet = []