Skip to content

Commit

Permalink
closes #2 adds automatic login to Einsatzmonitor in Chromium Browser
Browse files Browse the repository at this point in the history
  • Loading branch information
stg93 committed Sep 27, 2018
1 parent e798923 commit 8237540
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ sudo apt install cec-utils libcec4-dev
pip3 install pyyaml cec && sudo pip3 install pyyaml cec
```

Die Anzeige des blaulichtSMS Einstazmonitor Dashboards erfolgt im Chromium Browser, welcher standardmäßig auf Raspbian installiert ist. Das Einloggen in das Dashboard im Chromium Browser erfolgt nicht automatisch. Daher muss der Login einmal manuell in Chromium erfolgen. Bisher scheint es so, dass dieses manuelle Login nicht abläuft und somit nicht wiederholt werden muss.

## Installation
Zuerst muss via

Expand Down
6 changes: 4 additions & 2 deletions alarmmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def __init__(self):
config["blaulichtSMS Einsatzmonitor"]["password"]
)
self.hdmi_cec_controller = HdmiCecController()
self.browser_controller = ChromiumBrowserController()
session_id = self.blaulichtsms_controller.get_session()
self.browser_controller = ChromiumBrowserController(session_id)
self.browser_controller.start()

def _run_helper(self):
Expand Down Expand Up @@ -60,7 +61,8 @@ def _check_browser_status(self):
if not self.browser_controller.is_alive():
self.logger.warning(
"Browser is no longer running - restarting it")
self.browser_controller = ChromiumBrowserController()
session_id = self.blaulichtsms_controller.get_session()
self.browser_controller = ChromiumBrowserController(session_id)
self.browser_controller.start()

def run(self):
Expand Down
6 changes: 4 additions & 2 deletions alarmmonitortest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ def __init__(self):
config["blaulichtSMS Einsatzmonitor"]["password"]
)
self.hdmi_cec_controller = HdmiCecController()
self.browser_controller = ChromiumBrowserController()
session_id = self.blaulichtsms_controller.get_session()
self.browser_controller = ChromiumBrowserController(session_id)
self.browser_controller.start()

def _run_helper(self):
self.blaulichtsms_controller.is_alarm()
if not self.browser_controller.is_alive():
self.logger.warning(
"Browser is no longer running - restarting it")
self.browser_controller = ChromiumBrowserController()
session_id = self.blaulichtsms_controller.get_session()
self.browser_controller = ChromiumBrowserController(session_id)
self.browser_controller.start()
self.hdmi_cec_controller \
.power_on(duration=self._hdmi_cec_device_on_time)
Expand Down
4 changes: 2 additions & 2 deletions blaulichtsmscontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def __init__(self, customer_id, username, password):
self.username = username
self.password = password
self.last_alarm_check = datetime.now()
self.session = self._get_session()
self.session = self.get_session()

def _get_session(self):
def get_session(self):
try:
self.logger.info("Initialising blaulichtSMS session...")
content = {
Expand Down
6 changes: 4 additions & 2 deletions chromiumbrowsercontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ class ChromiumBrowserController:
blaulichtSMS Einsatzmonitor dashboard.
"""

def __init__(self):
def __init__(self, session_id):
self.logger = logging.getLogger(__name__)
self.session_id = session_id

def start(self):
self._delete_crash_exit()
Expand All @@ -24,7 +25,8 @@ def start(self):
"--disable-session-crashed-bubble",
"--disable-infobars",
"--start-fullscreen",
"https://dashboard.blaulichtsms.net"
"https://dashboard.blaulichtsms.net/#/login?token="
+ self.session_id
],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
Expand Down

0 comments on commit 8237540

Please sign in to comment.