本文整理汇总了Python中backend.Backend.has_cfg方法的典型用法代码示例。如果您正苦于以下问题:Python Backend.has_cfg方法的具体用法?Python Backend.has_cfg怎么用?Python Backend.has_cfg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend.Backend
的用法示例。
在下文中一共展示了Backend.has_cfg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SysAlertsPlugin
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import has_cfg [as 别名]
class SysAlertsPlugin(CategoryPlugin):
text = 'Alerts'
iconfont = 'gen-warning'
folder = 'bottom'
def on_init(self):
self.backend = Backend(self.app)
self.mon = ComponentManager.get().find('sysalerts-monitor')
def on_session_start(self):
self._settings = False
self._configuring = None
def get_counter(self):
lst = ComponentManager.get().find('sysalerts-monitor').get()
return len(filter(lambda x:x!='good', lst.values())) or None
def get_ui(self):
ui = self.app.inflate('sysalerts:main')
ostat = 'good'
stat = { 'good': 'info', 'susp': 'warn', 'dang': 'err' }
text = { 'good': 'GOOD', 'susp': 'WARNING', 'dang': 'DANGER' }
for m in sorted(self.mon.get(), key=lambda x:x.name):
st = self.mon.get()[m]
if st == 'susp' and ostat == 'good':
ostat = st
if st == 'dang':
ostat = st
ui.append('list', UI.DTR(
UI.StatusCell(status=stat[st], text=text[st]),
UI.DTD(
UI.Label(text=m.name, bold=True),
UI.Label(text=m.text),
),
UI.Label(
text=getattr(trans, 'trans_%s'%m.transform)(m.format_value())
),
UI.DTD(
UI.TipIcon(
iconfont="gen-pencil-2",
id='config/%s/%s'%(m.plugin_id,m.variant),
text='Configure',
),
),
))
if self._settings:
ui.append('main', self.get_ui_settings())
if self._configuring:
ui.append('main', getattr(self, 'get_ui_cfg_%s'%self._configuring.type)(self._configuring))
return ui
def get_ui_settings(self):
ui = self.app.inflate('sysalerts:settings')
for m in self.backend.list_meters():
for v in self.backend.list_variated(m):
ui.append('list', UI.DTR(
UI.DTD(
UI.Label(text=v.name, bold=True),
UI.Label(text=v.text),
),
UI.DTD(
UI.TipIcon(
iconfont="gen-pencil-2",
id='config/%s/%s'%(m.plugin_id,self.enc_file(v.variant)),
text='Configure',
),
UI.TipIcon(
iconfont="gen-cancel-circle",
id='disable/%s/%s'%(m.plugin_id,self.enc_file(v.variant)),
text='Disable',
) if self.backend.has_cfg(m.plugin_id,v.variant) else None,
),
))
return ui
def enc_file(self, path):
path = path.replace('//','/')
return base64.b64encode(path, altchars='+-').replace('=', '*')
def dec_file(self, b64):
return base64.b64decode(b64.replace('*', '='), altchars='+-')
@event('button/click')
def on_click(self, event, params, vars=None):
if params[0] == 'btnRefresh':
self.mon.refresh()
if params[0] == 'btnSettings':
self._settings = True
if params[0] == 'config':
self._configuring = self.backend.get_meter(params[1], self.dec_file(params[2]))
if params[0] == 'disable':
self.backend.del_cfg(params[1], self.dec_file(params[2]))
self.mon.refresh()
#.........这里部分代码省略.........
示例2: HealthPlugin
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import has_cfg [as 别名]
class HealthPlugin(CategoryPlugin):
text = 'Monitoramento'
icon = '/dl/health/icon.png'
folder = 'top'
def on_init(self):
self.backend = Backend(self.app)
self.mon = ComponentManager.get().find('health-monitor')
def on_session_start(self):
self._settings = False
self._configuring = None
def get_counter(self):
lst = ComponentManager.get().find('health-monitor').get()
return len(filter(lambda x:x!='good', lst.values())) or None
def get_ui(self):
ui = self.app.inflate('health:main')
ostat = 'good'
stat = { 'good': 'info', 'susp': 'warn', 'dang': 'err' }
text = { 'good': 'BOM', 'susp': 'ATENÇÃO', 'dang': 'PERIGO' }
for m in sorted(self.mon.get(), key=lambda x:x.name):
st = self.mon.get()[m]
if st == 'susp' and ostat == 'good':
ostat = st
if st == 'dang':
ostat = st
ui.append('list', UI.DTR(
UI.StatusCell(status=stat[st], text=text[st]),
UI.DTD(
UI.Label(text=m.name, bold=True),
UI.Label(text=m.text),
),
UI.Label(
text=getattr(trans, 'trans_%s'%m.transform)(m.format_value())
),
UI.DTD(
UI.TipIcon(
icon='/dl/core/ui/stock/edit.png',
id='config/%s/%s'%(m.plugin_id,m.variant),
text='Configurar',
),
),
))
if self._settings:
ui.append('main', self.get_ui_settings())
if self._configuring:
ui.append('main', getattr(self, 'get_ui_cfg_%s'%self._configuring.type)(self._configuring))
return ui
def get_ui_settings(self):
ui = self.app.inflate('health:settings')
for m in self.backend.list_meters():
for v in self.backend.list_variated(m):
ui.append('list', UI.DTR(
UI.DTD(
UI.Label(text=v.name, bold=True),
UI.Label(text=v.text),
),
UI.DTD(
UI.TipIcon(
icon='/dl/core/ui/stock/edit.png',
id='config/%s/%s'%(m.plugin_id,v.variant),
text='Configure',
),
UI.TipIcon(
icon='/dl/core/ui/stock/delete.png',
id='disable/%s/%s'%(m.plugin_id,v.variant),
text='Disable',
) if self.backend.has_cfg(m.plugin_id,v.variant) else None,
),
))
return ui
@event('button/click')
def on_click(self, event, params, vars=None):
if params[0] == 'btnRefresh':
self.mon.refresh()
if params[0] == 'btnSettings':
self._settings = True
if params[0] == 'config':
self._configuring = self.backend.get_meter(*params[1:])
if params[0] == 'disable':
self.backend.del_cfg(*params[1:])
self.mon.refresh()
@event('dialog/submit')
def on_submit(self, event, params, vars=None):
if params[0] == 'dlgSettings':
self._settings = False
if params[0] == 'dlgConfigure':
if vars.getvalue('action', None) == 'OK':
#.........这里部分代码省略.........
示例3: HealthPlugin
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import has_cfg [as 别名]
class HealthPlugin(CategoryPlugin):
text = "Health"
icon = "/dl/health/icon.png"
folder = "top"
def on_init(self):
self.backend = Backend(self.app)
self.mon = ComponentManager.get().find("health-monitor")
def on_session_start(self):
self._settings = False
self._configuring = None
def get_counter(self):
lst = ComponentManager.get().find("health-monitor").get()
return len(filter(lambda x: x != "good", lst.values())) or None
def get_ui(self):
ui = self.app.inflate("health:main")
ostat = "good"
stat = {"good": "info", "susp": "warn", "dang": "err"}
text = {"good": "GOOD", "susp": "WARNING", "dang": "DANGER"}
for m in sorted(self.mon.get(), key=lambda x: x.name):
st = self.mon.get()[m]
if st == "susp" and ostat == "good":
ostat = st
if st == "dang":
ostat = st
ui.append(
"list",
UI.DTR(
UI.StatusCell(status=stat[st], text=text[st]),
UI.DTD(UI.Label(text=m.name, bold=True), UI.Label(text=m.text)),
UI.Label(text=getattr(trans, "trans_%s" % m.transform)(m.format_value())),
UI.DTD(
UI.TipIcon(
icon="/dl/core/ui/stock/edit.png",
id="config/%s/%s" % (m.plugin_id, m.variant),
text="Configure",
)
),
),
)
if self._settings:
ui.append("main", self.get_ui_settings())
if self._configuring:
ui.append("main", getattr(self, "get_ui_cfg_%s" % self._configuring.type)(self._configuring))
return ui
def get_ui_settings(self):
ui = self.app.inflate("health:settings")
for m in self.backend.list_meters():
for v in self.backend.list_variated(m):
ui.append(
"list",
UI.DTR(
UI.DTD(UI.Label(text=v.name, bold=True), UI.Label(text=v.text)),
UI.DTD(
UI.TipIcon(
icon="/dl/core/ui/stock/edit.png",
id="config/%s/%s" % (m.plugin_id, v.variant),
text="Configure",
),
UI.TipIcon(
icon="/dl/core/ui/stock/delete.png",
id="disable/%s/%s" % (m.plugin_id, v.variant),
text="Disable",
)
if self.backend.has_cfg(m.plugin_id, v.variant)
else None,
),
),
)
return ui
@event("button/click")
def on_click(self, event, params, vars=None):
if params[0] == "btnRefresh":
self.mon.refresh()
if params[0] == "btnSettings":
self._settings = True
if params[0] == "config":
self._configuring = self.backend.get_meter(*params[1:])
if params[0] == "disable":
self.backend.del_cfg(*params[1:])
self.mon.refresh()
@event("dialog/submit")
def on_submit(self, event, params, vars=None):
if params[0] == "dlgSettings":
self._settings = False
if params[0] == "dlgConfigure":
if vars.getvalue("action", None) == "OK":
#.........这里部分代码省略.........