@@ 566-622 (lines=57) @@ | ||
563 | self.log("Frontend root:", self.frontend_root, lvl=debug) |
|
564 | self.frontend_watch_manager.add_watch(self.module_root, mask, rec=True) |
|
565 | ||
566 | def _instantiate_components(self, clear=True): |
|
567 | """Inspect all loadable components and run them""" |
|
568 | ||
569 | if clear: |
|
570 | # import objgraph |
|
571 | # from copy import deepcopy |
|
572 | from circuits.tools import kill |
|
573 | from circuits import Component |
|
574 | ||
575 | for comp in self.running_components.values(): |
|
576 | self.log(comp, type(comp), isinstance(comp, Component), pretty=True) |
|
577 | kill(comp) |
|
578 | # removables = deepcopy(list(self.runningcomponents.keys())) |
|
579 | # |
|
580 | # for key in removables: |
|
581 | # comp = self.runningcomponents[key] |
|
582 | # self.log(comp) |
|
583 | # comp.unregister() |
|
584 | # comp.stop() |
|
585 | # self.runningcomponents.pop(key) |
|
586 | # |
|
587 | # objgraph.show_backrefs([comp], |
|
588 | # max_depth=5, |
|
589 | # filter=lambda x: type(x) not in [list, tuple, set], |
|
590 | # highlight=lambda x: type(x) in [ConfigurableComponent], |
|
591 | # filename='backref-graph_%s.png' % comp.uniquename) |
|
592 | # del comp |
|
593 | # del removables |
|
594 | self.running_components = {} |
|
595 | ||
596 | self.log( |
|
597 | "Not running blacklisted components: ", self.component_blacklist, lvl=debug |
|
598 | ) |
|
599 | ||
600 | running = set(self.loadable_components.keys()).difference( |
|
601 | self.component_blacklist |
|
602 | ) |
|
603 | self.log("Starting components: ", sorted(running)) |
|
604 | for name, componentdata in self.loadable_components.items(): |
|
605 | if name in self.component_blacklist: |
|
606 | continue |
|
607 | self.log("Running component: ", name, lvl=verbose) |
|
608 | try: |
|
609 | if name in self.running_components: |
|
610 | self.log("Component already running: ", name, lvl=warn) |
|
611 | else: |
|
612 | runningcomponent = componentdata() |
|
613 | runningcomponent.register(self) |
|
614 | self.running_components[name] = runningcomponent |
|
615 | except Exception as e: |
|
616 | self.log( |
|
617 | "Could not register component: ", |
|
618 | name, |
|
619 | e, |
|
620 | type(e), |
|
621 | lvl=error, |
|
622 | exc=True, |
|
623 | ) |
|
624 | ||
625 | def started(self, component): |
@@ 643-704 (lines=62) @@ | ||
640 | self.log("Installing missing provisions:", missing_provisions) |
|
641 | provision(installed=provisioned_packages) |
|
642 | ||
643 | def _instantiate_components(self, clear=True): |
|
644 | """Inspect all loadable components and run them""" |
|
645 | ||
646 | if clear: |
|
647 | # import objgraph |
|
648 | # from copy import deepcopy |
|
649 | from circuits.tools import kill |
|
650 | from circuits import Component |
|
651 | ||
652 | for comp in self.loaded_components.values(): |
|
653 | self.log(comp, type(comp), isinstance(comp, Component), pretty=True) |
|
654 | kill(comp) |
|
655 | # removables = deepcopy(list(self.runningcomponents.keys())) |
|
656 | # |
|
657 | # for key in removables: |
|
658 | # comp = self.runningcomponents[key] |
|
659 | # self.log(comp) |
|
660 | # comp.unregister() |
|
661 | # comp.stop() |
|
662 | # self.runningcomponents.pop(key) |
|
663 | # |
|
664 | # objgraph.show_backrefs([comp], |
|
665 | # max_depth=5, |
|
666 | # filter=lambda x: type(x) not in [list, tuple, set], |
|
667 | # highlight=lambda x: type(x) in [ConfigurableComponent], |
|
668 | # filename='backref-graph_%s.png' % comp.uniquename) |
|
669 | # del comp |
|
670 | # del removables |
|
671 | self.loaded_components = {} |
|
672 | ||
673 | self.log( |
|
674 | "Not running blacklisted components: ", self.component_blacklist, lvl=debug |
|
675 | ) |
|
676 | ||
677 | running = set(self.loadable_components.keys()).difference( |
|
678 | self.component_blacklist |
|
679 | ) |
|
680 | self.log("Starting components: ", sorted(running)) |
|
681 | for name, componentdata in self.loadable_components.items(): |
|
682 | if name in self.component_blacklist: |
|
683 | continue |
|
684 | self.log("Running component: ", name, lvl=debug) |
|
685 | try: |
|
686 | if name in self.loaded_components: |
|
687 | self.log("Component already running: ", name, lvl=warn) |
|
688 | else: |
|
689 | try: |
|
690 | runningcomponent = componentdata() |
|
691 | except ComponentDisabled: |
|
692 | self.log("Not registering disabled component", lvl=debug) |
|
693 | continue |
|
694 | ||
695 | runningcomponent.register(self) |
|
696 | self.loaded_components[name] = runningcomponent |
|
697 | except Exception as e: |
|
698 | self.log( |
|
699 | "Could not register component: ", |
|
700 | name, |
|
701 | e, |
|
702 | type(e), |
|
703 | lvl=error, |
|
704 | exc=True, |
|
705 | ) |
|
706 | ||
707 | def started(self, component): |