add a way to change the default level of a context's children
This commit is contained in:
parent
a91dff2b14
commit
45478b68a4
|
@ -45,21 +45,24 @@ class Context:
|
|||
context.description = "result was {}".format(result)
|
||||
"""
|
||||
|
||||
def __init__(self, app, name, description, parent, level):
|
||||
def __init__(self, app, name, description, parent, level, childlevel=None):
|
||||
self.app = app
|
||||
self.name = name
|
||||
self.description = description
|
||||
self.parent = parent
|
||||
self.level = level
|
||||
if childlevel is None:
|
||||
childlevel = level
|
||||
self.childlevel = childlevel
|
||||
|
||||
@classmethod
|
||||
def new(self, app):
|
||||
return Context(app, app.project, "", None, "INFO")
|
||||
|
||||
def child(self, name, description="", level=None):
|
||||
def child(self, name, description="", level=None, childlevel=None):
|
||||
if level is None:
|
||||
level = self.level
|
||||
return Context(self.app, name, description, self, level)
|
||||
level = self.childlevel
|
||||
return Context(self.app, name, description, self, level, childlevel)
|
||||
|
||||
def _name(self):
|
||||
c = self
|
||||
|
|
|
@ -36,7 +36,7 @@ class BaseController(ABC):
|
|||
self.opts = app.opts
|
||||
self.loop = app.loop
|
||||
self.app = app
|
||||
self.context = self.app.context.child(self.name)
|
||||
self.context = self.app.context.child(self.name, childlevel="DEBUG")
|
||||
self.answers = app.answers.get(self.name, {})
|
||||
if self.model_name is not None:
|
||||
self.model = getattr(self.app.base_model, self.model_name)
|
||||
|
|
|
@ -348,7 +348,8 @@ class NetworkController(BaseController):
|
|||
self.model.parse_netplan_configs(self.root)
|
||||
|
||||
async def _apply_config(self, silent):
|
||||
with self.context.child("apply_config", "silent={}".format(silent)):
|
||||
with self.context.child(
|
||||
"apply_config", "silent={}".format(silent), level="INFO"):
|
||||
devs_to_delete = []
|
||||
devs_to_down = []
|
||||
dhcp_device_versions = []
|
||||
|
|
|
@ -66,8 +66,7 @@ log = logging.getLogger('subiquitycore.views.network')
|
|||
def _stretchy_shower(cls, *args):
|
||||
def impl(self, name, device):
|
||||
stretchy = cls(self, device, *args)
|
||||
stretchy.attach_context(
|
||||
self.controller.context.child(name, level="DEBUG"))
|
||||
stretchy.attach_context(self.controller.context.child(name))
|
||||
self.show_stretchy_overlay(stretchy)
|
||||
impl.opens_dialog = True
|
||||
return impl
|
||||
|
@ -380,8 +379,7 @@ class NetworkView(BaseView):
|
|||
|
||||
def _create_bond(self, sender=None):
|
||||
stretchy = BondStretchy(self)
|
||||
stretchy.attach_context(
|
||||
self.controller.context.child("add_bond", level="DEBUG"))
|
||||
stretchy.attach_context(self.controller.context.child("add_bond"))
|
||||
self.show_stretchy_overlay(stretchy)
|
||||
|
||||
def show_network_error(self, action, info=None):
|
||||
|
|
Loading…
Reference in New Issue