我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用log.getvalue()。
def __init__(self, session): self.session = session Screen.__init__(self, session) self.setTitle(_("Positioner setup log")) self["key_red"] = Button(_("Exit/OK")) self["key_green"] = Button(_("Save")) self["key_blue"] = Button(_("Clear")) self["list"] = ScrollLabel(log.getvalue()) self["actions"] = ActionMap(["DirectionActions", "OkCancelActions", "ColorActions"], { "red": self.cancel, "green": self.save, "save": self.save, "blue": self.clear, "cancel": self.cancel, "ok": self.cancel, "left": self["list"].pageUp, "right": self["list"].pageDown, "up": self["list"].pageUp, "down": self["list"].pageDown, "pageUp": self["list"].pageUp, "pageDown": self["list"].pageDown }, -2)
def __init__(self, session): self.session = session Screen.__init__(self, session) Screen.setTitle(self, _("AutoBouquetsMaker Log")) self["list"] = ScrollLabel(log.getvalue()) self["setupActions"] = ActionMap(["SetupActions", "ColorActions", "DirectionActions", "MenuActions"], { "cancel": self.cancel, "ok": self.cancel, "up": self["list"].pageUp, "down": self["list"].pageDown, "menu": self.closeRecursive, "green": self.save, }, -2) self["key_green"] = Button(_("Save Log")) self["key_red"] = Button(_("Close"))
def save(self): try: f = open('/tmp/positionersetup.log', 'w') f.write(log.getvalue()) f.close() self.session.open(MessageBox, _("Write to /tmp/positionersetup.log"), MessageBox.TYPE_INFO, timeout = 5) except Exception, e: self["list"].setText(_("Failed to write /tmp/positionersetup.log: ") + str(e)) self.close(True)
def save(self): output = open('/tmp/abm.log', 'w') output.write(log.getvalue()) output.close() self.session.open(MessageBox,_("ABM log file has been saved to the tmp directory"),MessageBox.TYPE_INFO, timeout = 45)