当前位置: 首页>>代码示例>>Python>>正文


Python OpenIPMI.color_string方法代码示例

本文整理汇总了Python中OpenIPMI.color_string方法的典型用法代码示例。如果您正苦于以下问题:Python OpenIPMI.color_string方法的具体用法?Python OpenIPMI.color_string怎么用?Python OpenIPMI.color_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenIPMI的用法示例。


在下文中一共展示了OpenIPMI.color_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import OpenIPMI [as 别名]
# 或者: from OpenIPMI import color_string [as 别名]
    def __init__(self, e, control):
        self.e = e
        self.name = control.get_name()
        e.controls[self.name] = self
        self.control_type_str = control.get_type_string()
        self.control_id = control.get_id()
        self.ui = e.ui;
        self.updater = ControlRefreshData(self)
        self.vals = [ ]
        self.ui.add_control(self.e, self)
        self.control_type = control.get_type()
        self.destroyed = False
        if (self.control_type == OpenIPMI.CONTROL_IDENTIFIER):
            self.num_vals = control.identifier_get_max_length();
        else:
            self.num_vals = control.get_num_vals();
            pass

        if ((self.control_type == OpenIPMI.CONTROL_LIGHT)
            and (control.light_set_with_setting())):
            self.setting_light = True
            self.lights = [ ]
            for  i in range (0, self.num_vals):
                lc = control.light_has_local_control(i)
                colors = [ ]
                for j in range (0, OpenIPMI.CONTROL_NUM_COLORS):
                    if control.light_is_color_supported(i, j):
                        colors.append(OpenIPMI.color_string(j))
                        pass
                    pass
                self.lights.append((lc, colors))
                pass
            pass
        else:
            self.setting_light = False
            pass

        self.is_settable = control.is_settable()
        self.is_readable = control.is_readable()
        if (self.is_settable):
            if (self.setting_light):
                self.setter = LightSet(self)
            else:
                self.setter = ControlSet(self)
                pass
            pass
        else:
            self.setter = None
            pass

        self.ui.prepend_item(self, "Control Type", self.control_type_str)
        cs = [ ]
        if (control.has_events()):
            cs.append("generates_events")
            pass
        if (self.is_settable):
            cs.append("settable")
            pass
        if (self.is_readable):
            cs.append("readable")
            pass
        self.ui.append_item(self, "Control Capabilities", ' '.join(cs))
        if (self.control_type == OpenIPMI.CONTROL_LIGHT):
            self.ui.append_item(self, "Num Lights", str(self.num_vals))
            if (self.setting_light):
                self.ui.append_item(self, "Light Type", "setting")
                for i in range(0, self.num_vals):
                    cap = [ ]
                    if control.light_has_local_control(i):
                        cap.append("local_control")
                        pass
                    for j in range (0, OpenIPMI.CONTROL_NUM_COLORS):
                        if control.light_is_color_supported(i, j):
                            cap.append(OpenIPMI.color_string(j))
                            pass
                        pass
                    self.ui.append_item(self, "Light" + str(i), ' '.join(cap))
                    pass
                pass
            else:
                self.ui.append_item(self, "Light Type", "transition")
                for i in range(0, self.num_vals):
                    cap = [ ]
                    for j in range (0, control.get_num_light_values(i)):
                        cap2 = [ ]
                        for k in range (0,control.get_num_light_transitions(i, j)):
                            cap3 = [ ]
                            val = control.get_light_color(i, j, k)
                            cap3.append(OpenIPMI.color_string(val))
                            val = control.get_light_color_time(i, j, k)
                            cap3.append(OpenIPMI.color_string(val))
                            cap2.append(cap3)
                            pass
                        cap.append(cap2)
                        pass
                    self.ui.append_item(self, "Light" + str(i), str(cap))
                    pass
                pass
            pass
        elif (self.control_type == OpenIPMI.CONTROL_IDENTIFIER):
#.........这里部分代码省略.........
开发者ID:sharkconi,项目名称:openipmi,代码行数:103,代码来源:_control.py

示例2: entity_control_update_cb

# 需要导入模块: import OpenIPMI [as 别名]
# 或者: from OpenIPMI import color_string [as 别名]
    def entity_control_update_cb(self, op, entity, control):
	use_setting = 0

	print op + " control " + control.get_name()
        if ((op == "added") or (op == "changed")):
	    t = control.get_type()
	    print "  type = " + str(t)
	    print "  entity_id = " + str(control.get_entity_id())
	    print "  entity_instance = " + str(control.get_entity_instance())
	    print "  settable = " + str(control.is_settable())
	    print "  readable = " + str(control.is_readable())
	    print("  ignore_if_no_entity = " +
		  str(control.get_ignore_if_no_entity()))
	    print "  control_id = " + str(control.get_control_id())
	    print "  has_events = " + str(control.has_events())
	    num_vals = control.get_num_vals()
	    print "  num_vals = " + str(num_vals)

            if t == OpenIPMI.CONTROL_LIGHT:
		use_setting = control.light_set_with_setting()
                pass

	    if use_setting:
		print "  light controlled with setting"
		tstr = "  Colors: "
                for i in range(0, OpenIPMI.CONTROL_NUM_COLORS):
                    if (control.light_is_color_supported(i)):
			tstr += " " + OpenIPMI.color_string(i) + ("(%d)" % i)
                        pass
                    pass
		print tstr
		print("  light_has_local_control = " +
		      str(control.light_has_local_control()))
		rv = control.ipmi_control_get_light(self)
                if rv:
		    print "***Error getting light: " + str(rv)
                    pass
                pass
	    elif t == OpenIPMI.CONTROL_IDENTIFIER:
		print("  identifier_get_max_length = " +
		      str(control.identifier_get_max_length()))
		rv = control.identifier_get_val(self)
                if rv:
		    print "***Error getting control id: " + str(rv)
                    pass
                pas
            elif t == OpenIPMI.CONTROL_LIGHT:
                for i in range(0, num_vals) :
                    n = control.get_num_light_values(i)
                    print "  Light %d" % i
                    for j in range (0, n):
                        print "    Value %d" % j
                        o = control.get_num_light_transitions(i, j)
                        for k in range (0, o):
                            tstr = "    Transition %d:" & k
                            v = control.get_light_color(i, j, k)
                            tstr += " " + OpenIPMI.color_string(v)
                            v = control.get_light_color_time(i, j, k)
                            tstr += " time(" + str(v) + ")"
                            pass
                        pass
                    pass
                pass

            if op == "added":
		rv = control.add_event_handler(self)
                if rv:
		    print "***Error adding control event handler: " + str(rv)
                    pass
                pass
            pass
        elif op == "deleted":
	    rv = control.remove_event_handler(self)
            if rv:
		print "***Error removing control event handler: " + str(rv)
                pass
            pass
        return
开发者ID:sharkconi,项目名称:openipmi,代码行数:80,代码来源:sample.py


注:本文中的OpenIPMI.color_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。