From d43afc9f73b40856f1fd8b2f8ada839132d4ed90 Mon Sep 17 00:00:00 2001 From: Benedikt Seeger <benedikt.seeger@ptb.de> Date: Thu, 25 Apr 2024 14:54:56 +0200 Subject: [PATCH] changed start method of docker file --- dockerfile | 13 ++----------- main.py | 36 ++++++++++++++++++++++++++++++------ startkBokehAndPrintIp.sh | 13 +++++++++++++ 3 files changed, 45 insertions(+), 17 deletions(-) create mode 100755 startkBokehAndPrintIp.sh diff --git a/dockerfile b/dockerfile index e2e4f68..8aaf67c 100644 --- a/dockerfile +++ b/dockerfile @@ -2,22 +2,13 @@ FROM python:3.11 # WORKDIR /usr/src/app ENV GIT_SSL_NO_VERIFY=1 -# Set the environment variable for the HTTP proxy -#ENV http_proxy="http://webproxy.bs.ptb.de:8080" -#ENV https_proxy="http://webproxy.bs.ptb.de:8080" - -# Set the environment variable for the NO_PROXY -# This ensures that the proxy is not used for ptb.de -#ENV no_proxy="ptb.de" # Install any needed packages specified in requirements.txt RUN git clone https://gitlab1.ptb.de/digitaldynamicmeasurement/dsi-parser-frontend.git -#RUN pip install --proxy=webproxy.bs.ptb.de:8080 --no-cache-dir -r dsi-parser-frontend/requirements.txt - RUN pip install --no-cache-dir -r dsi-parser-frontend/requirements.txt EXPOSE 5020 - -CMD ["bokeh", "serve", "dsi-parser-frontend/", "--port", "5020", "--allow-websocket-origin", "*","--use-xheaders","--prefix","dsi-parser-frontend"] +CMD ["./startkBokehAndPrintIp.sh"] +#CMD ["bokeh", "serve", "dsi-parser-frontend/", "--port", "5020", "--allow-websocket-origin", "*","--use-xheaders","--prefix","dsi-parser-frontend"] diff --git a/main.py b/main.py index bda33e5..be32efa 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,19 @@ -import base64 -import io -import json -import tarfile +# This file is part of dsiUnitsFrontend (https://gitlab1.ptb.de/digitaldynamicmeasurement/dsi-parser-frontend) +# Copyright 2024 [Benedikt Seeger(PTB), Vanessa Stehr(PTB)] +#This library is free software; you can redistribute it and/or +#modify it under the terms of the GNU Lesser General Public +#License as published by the Free Software Foundation; either +#version 2.1 of the License, or (at your option) any later version. + +#This library is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +#Lesser General Public License for more details. + +#You should have received a copy of the GNU Lesser General Public +#License along with this library; if not, write to the Free Software +#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + import warnings import itertools import math @@ -16,6 +28,19 @@ from bokeh.events import ValueSubmit import numpy as np colors=Category10[10] VERSION = "0.1.0" +import socket + +def get_local_ip(): + try: + # Creates a socket connection to Google's public DNS server to determine the internal network IP + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: + s.connect(("8.8.8.8", 80)) # Using Google DNS, and connecting via dummy request + local_ip = s.getsockname()[0] # Returns the IP where the socket is connected + return local_ip + except Exception as e: + return f"Unable to get IP: {e}" + + issueTemplate="""There was an issue with the following unit conversion: @@ -284,9 +309,7 @@ class page(): issueUrl = r'https://gitlab1.ptb.de/digitaldynamicmeasurement/dsi-parser-frontend/-/issues/new?' title = quote(filledTitle) body = quote(filledResult) - url = issueUrl + 'issue[title]=' + title + '&issue[description]=' + body - return url def clearComparison(self): @@ -300,4 +323,5 @@ class page(): if self.dsiInput1.valideUnit and self.dsiInput2.valideUnit: self.compare() + thisPage = page() diff --git a/startkBokehAndPrintIp.sh b/startkBokehAndPrintIp.sh new file mode 100755 index 0000000..1214432 --- /dev/null +++ b/startkBokehAndPrintIp.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Find the local IP address. This line gets the IP address associated with the default route. +LOCAL_IP=$(ip route get 1 | awk '{print $7;exit}') + +# Print the local IP address +echo "Local IP Address: $LOCAL_IP" + +# Run the Bokeh server command +CMD=("bokeh" "serve" "./" "--port" "5020" "--allow-websocket-origin" "*" "--use-xheaders" "--prefix" "dsi-parser-frontend") + +# Execute the command +"${CMD[@]}" \ No newline at end of file -- GitLab