MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / __init__

Method __init__

shared.py:195–289  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

193 "st7735s": {"ref_width": 128, "ref_height": 128, "default_flip": False},
194 # Whisplay HAT 1.69" ST7789 240x280 colour TFT LCD (ref height keeps the
195 # 240:280 aspect so the layout isn't stretched: 122 * 280/240 = 142)
196 "whisplay": {"ref_width": DESIGN_REF_WIDTH, "ref_height": 142, "default_flip": False},
197 # SSD1306 0.96" 128x64 monochrome OLED
198 "ssd1306": {"ref_width": 128, "ref_height": 64, "default_flip": False},
199 # LCD1602 16x2 character LCD (I2C via PCF8574 backpack)
200 "lcd1602": {"ref_width": 16, "ref_height": 2, "default_flip": False},
201 # MAX7219 LED matrix displays
202 "max7219_4panel": {"ref_width": 32, "ref_height": 8, "default_flip": False},
203 "max7219_8panel": {"ref_width": 64, "ref_height": 8, "default_flip": False},
204}
205
206
207logger = Logger(name="shared.py", level=logging.DEBUG) # Create a logger object
208
209class SharedData:
210 """Shared data between the different modules."""
211 def __init__(self):
212 # Detect Pager mode (set by pager_payload.sh before Python launch)
213 self._pager_mode = os.environ.get('RAGNAR_PAGER_MODE') == '1'
214 # Detect Headless mode (set by headlessRagnar.py / systemd on web-only
215 # installs). Like Pager mode it must never initialize the EPD, which
216 # would seize SPI0 + GPIO and blank a DPI/HDMI panel on shared-pin
217 # boards (HackBerry Pi and similar).
218 self._headless_mode = os.environ.get('RAGNAR_HEADLESS') == '1'
219
220 self.initialize_paths() # Initialize the paths used by the application
221
222 # --- Network storage & context (not available on Pager) ---
223 if not self._pager_mode and NetworkStorageManager is not None:
224 self.storage_manager = NetworkStorageManager(self.datadir)
225 else:
226 self.storage_manager = None
227 self.active_network_ssid = None
228 self.active_network_slug = None
229 self.current_network_dir = None
230 self.current_network_db_path = None
231 self.network_intelligence_dir = None
232 self.network_threat_dir = None
233 if self.storage_manager is not None:
234 self._apply_network_context(
235 self.storage_manager.get_active_context(),
236 configure_db=False
237 )
238 if not self._pager_mode and NetworkContextRegistry is not None:
239 self.context_registry = NetworkContextRegistry(self)
240 else:
241 self.context_registry = None
242
243 self.status_list = []
244 self.last_comment_time = time.time() # Last time a comment was displayed
245 self._stats_lock = threading.Lock() # Thread-safe lock for update_stats()
246 self._config_lock = threading.RLock() # Serializes save_config() vs mutations
247 self.default_config = self.get_default_config() # Default configuration of the application
248 self.config = self.default_config.copy() # Configuration of the application
249 # Load existing configuration first
250 self.load_config()
251
252 if not self._pager_mode and MultiInterfaceState is not None:

Callers

nothing calls this directly

Calls 15

initialize_pathsMethod · 0.95
get_default_configMethod · 0.95
load_configMethod · 0.95
apply_display_profileMethod · 0.95
_configure_databaseMethod · 0.95
update_mac_blacklistMethod · 0.95
setup_environmentMethod · 0.95
initialize_variablesMethod · 0.95
create_livestatusfileMethod · 0.95

Tested by

no test coverage detected