Read data from SQLite database. Returns data in the same format as CSV for backward compatibility.
(self)
| 1867 | raise |
| 1868 | |
| 1869 | def _get_image_scale(self): |
| 1870 | """Get the image scale factor for the current display. |
| 1871 | For small displays (2.13", 2.7") icons stay at native size. |
| 1872 | For large displays (4.26" 800x480) icons scale up proportionally.""" |
| 1873 | sy = getattr(self, 'scale_factor_y', 1.0) |
| 1874 | if sy > 1.5: # Large display (e.g. 4.26") |
| 1875 | return sy |
| 1876 | return 1.0 |
| 1877 | |
| 1878 | def load_images(self): |
| 1879 | """Load the images for the e-paper display, scaled for display size.""" |
| 1880 | try: |
| 1881 | logger.info("Loading images...") |
| 1882 | img_scale = self._get_image_scale() |
| 1883 | |
| 1884 | # Load static images from the root of staticpicdir |
| 1885 | self.ragnarstatusimage = None |
| 1886 | self.ragnar1 = self.load_image(os.path.join(self.staticpicdir, 'ragnar1.bmp'), scale=img_scale) |
| 1887 | self.port = self.load_image(os.path.join(self.staticpicdir, 'port.bmp'), scale=img_scale) |
| 1888 | self.frise = self.load_image(os.path.join(self.staticpicdir, 'frise.bmp')) |
| 1889 | self.target = self.load_image(os.path.join(self.staticpicdir, 'target.bmp'), scale=img_scale) |
| 1890 | self.vuln = self.load_image(os.path.join(self.staticpicdir, 'vuln.bmp'), scale=img_scale) |
| 1891 | self.connected = self.load_image(os.path.join(self.staticpicdir, 'connected.bmp'), scale=img_scale) |
| 1892 | self.bluetooth = self.load_image(os.path.join(self.staticpicdir, 'bluetooth.bmp'), scale=img_scale) |
| 1893 | self.wifi = self.load_image(os.path.join(self.staticpicdir, 'wifi.bmp'), scale=img_scale) |
| 1894 | self.ethernet = self.load_image(os.path.join(self.staticpicdir, 'ethernet.bmp'), scale=img_scale) |
| 1895 | self.usb = self.load_image(os.path.join(self.staticpicdir, 'usb.bmp'), scale=img_scale) |
| 1896 | self.level = self.load_image(os.path.join(self.staticpicdir, 'level.bmp'), scale=img_scale) |
| 1897 | self.cred = self.load_image(os.path.join(self.staticpicdir, 'cred.bmp'), scale=img_scale) |
| 1898 | self.attack = self.load_image(os.path.join(self.staticpicdir, 'attack.bmp'), scale=img_scale) |
| 1899 | self.attacks = self.load_image(os.path.join(self.staticpicdir, 'attacks.bmp'), scale=img_scale) |
| 1900 | self.gold = self.load_image(os.path.join(self.staticpicdir, 'gold.bmp'), scale=img_scale) |
| 1901 | self.networkkb = self.load_image(os.path.join(self.staticpicdir, 'networkkb.bmp'), scale=img_scale) |
| 1902 | self.zombie = self.load_image(os.path.join(self.staticpicdir, 'zombie.bmp'), scale=img_scale) |
| 1903 | self.data = self.load_image(os.path.join(self.staticpicdir, 'data.bmp'), scale=img_scale) |
| 1904 | self.money = self.load_image(os.path.join(self.staticpicdir, 'money.bmp'), scale=img_scale) |
| 1905 | self.zombie_status = self.load_image(os.path.join(self.staticpicdir, 'zombie.bmp'), scale=img_scale) |
| 1906 | self.attack = self.load_image(os.path.join(self.staticpicdir, 'attack.bmp'), scale=img_scale) |
| 1907 | |
| 1908 | # Resize frise to span full display width (and scale height on large displays) |
| 1909 | if self.frise is not None and Image is not None and hasattr(self, 'width') and self.frise.width < self.width: |
| 1910 | new_h = max(self.frise.height, int(self.frise.height * img_scale)) if img_scale > 1.0 else self.frise.height |
| 1911 | self.frise = self.frise.resize((self.width - 2, new_h), Image.Resampling.NEAREST) |
| 1912 | |
| 1913 | """ Load the images for the different actions status""" |
| 1914 | # Dynamically load status images based on actions.json |
| 1915 | try: |
| 1916 | with open(self.actions_file, 'r') as f: |
| 1917 | actions = json.load(f) |
| 1918 | for action in actions: |
| 1919 | b_class = action.get('b_class') |
| 1920 | if b_class: |
| 1921 | indiv_status_path = os.path.join(self.statuspicdir, b_class) |
| 1922 | image_path = os.path.join(indiv_status_path, f'{b_class}.bmp') |
| 1923 | image = self.load_image(image_path, scale=img_scale) |
| 1924 | setattr(self, b_class, image) |
| 1925 | logger.info(f"Loaded image for {b_class} from {image_path}") |
| 1926 | except Exception as e: |
no test coverage detected