def update(self, update_params: Dict[str, Any]) -> None:
async def _run(cur: sql.Cursor) -> None:
for param in ['name', 'description', 'active', 'cmdline_filename', 'cmdline_args_tmpl', 'description_tmpl']:
if param in update_params:
q = """update active_monitor_defs set %s=%%s where id=%%s""" % param
q_args = (update_params[param], self.id)
await cur.execute(q, q_args)
self.log_msg('updating monitor def')
if 'name' in update_params:
self.name = update_params['name']
if 'active' in update_params:
self.active = update_params['active']
if 'cmdline_filename' in update_params:
self.cmdline_filename = update_params['cmdline_filename']
if 'cmdline_args_tmpl' in update_params:
self.cmdline_args_tmpl = update_params['cmdline_args_tmpl']
self.jinja_cmdline_args = jinja2.Template(self.cmdline_args_tmpl)
if 'description_tmpl' in update_params:
self.description_tmpl = update_params['description_tmpl']
self.jinja_description_tmpl = jinja2.Template(self.description_tmpl)
self.tmpl_cache.flush_all()
await self.manager.dbcon.transact(_run)
评论列表
文章目录