From d17a7770d67ce6e9d68680ea1c4a587c80fe7aed Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Tue, 9 Sep 2025 20:44:48 +0200 Subject: [PATCH] Show IP address --- buba/animationconfig.py | 4 ++-- buba/animations/time.py | 5 +++-- buba/appconfig.py | 6 ++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/buba/animationconfig.py b/buba/animationconfig.py index fcb85dc..c8a7584 100644 --- a/buba/animationconfig.py +++ b/buba/animationconfig.py @@ -17,7 +17,7 @@ LOG = logging.getLogger(__name__) def setup_animations(config, animator: BubaAnimator, webqueue: WebQueue): cs = BubaCharset(animator.buba) - bt = BubaTime(animator.buba) + bt = BubaTime(animator.buba, config.ip) snake = SnakeAnimation(animator.buba) @@ -46,7 +46,7 @@ def setup_animations(config, animator: BubaAnimator, webqueue: WebQueue): # animator.add(cs) animator.add(bt) - # animator.add(snake) + animator.add(snake) animator.add(dbf_ahst) animator.add(dbf_ahs) animator.add(ccchh_events) diff --git a/buba/animations/time.py b/buba/animations/time.py index 8d0cb7a..78ef2f1 100644 --- a/buba/animations/time.py +++ b/buba/animations/time.py @@ -6,13 +6,14 @@ from buba.bubacmd import BubaCmd class BubaTime(BubaAnimation): - def __init__(self, buba: BubaCmd): + def __init__(self, buba: BubaCmd, ip:str): super().__init__(buba) + self.ip = ip def show(self): self.buba.text(page=0, row=0, col_start=0, col_end=119, text="Chaos Computer Club", align=BubaCmd.ALIGN_CENTER) self.buba.text(page=0, row=1, col_start=0, col_end=119, text="Hansestadt Hamburg", align=BubaCmd.ALIGN_CENTER) - self.buba.text(page=0, row=2, col_start=0, col_end=119, text="", align=BubaCmd.ALIGN_CENTER) + self.buba.text(page=0, row=2, col_start=0, col_end=119, text=f"{self.ip}", align=BubaCmd.ALIGN_CENTER) self.buba.text(page=0, row=3, col_start=0, col_end=119, text=datetime.now().strftime("%Y-%m-%d %H:%M"), align=BubaCmd.ALIGN_CENTER) sleep(10) diff --git a/buba/appconfig.py b/buba/appconfig.py index 8f96d3f..89befaf 100644 --- a/buba/appconfig.py +++ b/buba/appconfig.py @@ -22,3 +22,9 @@ class AppConfig: self.debug = True else: self.debug = False + + import socket + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.connect(("8.8.8.8", 80)) + self.ip = s.getsockname()[0] + s.close()