diff options
author | PA4WDH | 2025-07-27 16:29:19 +0200 |
---|---|---|
committer | PA4WDH | 2025-07-27 16:29:19 +0200 |
commit | 1f35ebe4e439d6cbe09dcc401ac997858455d647 (patch) | |
tree | f927eb1da937bf20e9238840a8438226dca41b2a | |
parent | Improve logging of reference image (diff) | |
download | qemu.py-1f35ebe4e439d6cbe09dcc401ac997858455d647.tar.gz qemu.py-1f35ebe4e439d6cbe09dcc401ac997858455d647.tar.bz2 qemu.py-1f35ebe4e439d6cbe09dcc401ac997858455d647.zip |
Improve image logging in wait_for_screen
-rw-r--r-- | qemu.py | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -216,11 +216,18 @@ div.active { def tabs(self,tabdata): self.tabgroup=self.tabgroup+1 htmldoc,htmltag,htmltext=Doc().tagtext() + activetab=0 + + for tab in range(len(tabdata)): + if "active" in tabdata[tab]: + if tabdata[tab]["active"]: + activetab=tab + break with htmltag("div",klass="tab"): for tab in range(len(tabdata)): klass=f"group{self.tabgroup} tablinks" - if tab==0: + if tab==activetab: klass=klass+" active" if "name" not in tabdata[tab]: tabdata[tab]["name"]=str(tab) @@ -229,7 +236,7 @@ div.active { for tab in range(len(tabdata)): klass=f"group{self.tabgroup} tabcontent" - if tab==0: + if tab==activetab: klass=klass+" active" with htmltag("div",id=tab,klass=klass): with htmltag("h3"): @@ -676,24 +683,28 @@ class vm: refimage=Image.open(filename) now=datetime.now().timestamp() imagelog.append({"name": "Reference", "text": filename, "image": refimage.copy()}) - + if mask!=None: + self.apply_mask(refimage,mask,"#ff0000") + imagelog.append({"name": "With mask", "text": filename, "image": refimage.copy()}) refimage.close() check=0 + active=True while check<timeout: result=self.screenshot_diff(filename,mask,log=False) now=datetime.now().timestamp() if result==None: - imagelog.append({"name": "Final", "timestamp": now, "image": self.screenshot_image(log=False)}) + imagelog.append({"name": "Final", "timestamp": now, "image": self.screenshot_image(log=False), "active": active}) print(f"Check {check}: Screen is similar to {filename}") self.log.tabs(imagelog) return True print(f"Check {check}: Screen is not similar to {filename}") - imagelog.append({"name": f"Check {check}", "timestamp": now, "image": result.copy()}) + imagelog.append({"name": f"Check {check}", "timestamp": now, "image": result.copy(), "active": active}) result.close() if callback!=None: callback() sleep(interval) check=check+1 + active=False now=datetime.now().timestamp() imagelog.append({"name": "Final", "timestamp": now, "image": self.screenshot_image(log=False)}) self.log.tabs(imagelog) |