anzeige IP
This commit is contained in:
+17
-2
@@ -4,6 +4,20 @@ import toml
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from urllib.request import urlopen
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def get_public_ip():
|
||||||
|
data = str(urlopen('http://checkip.dyndns.com/').read())
|
||||||
|
return re.compile(r'Address: (\d+.\d+.\d+.\d+)').search(data).group(1)
|
||||||
|
|
||||||
|
|
||||||
|
def read_datei(datei):
|
||||||
|
with open(os.path.join(CONFIG["pfad_cloud"], datei)) as file:
|
||||||
|
inhalt = file.read()
|
||||||
|
inhalt = inhalt.strip()
|
||||||
|
return inhalt
|
||||||
|
|
||||||
|
|
||||||
class EmpyrionLauncher(QtWidgets.QDialog):
|
class EmpyrionLauncher(QtWidgets.QDialog):
|
||||||
@@ -29,7 +43,7 @@ class EmpyrionLauncher(QtWidgets.QDialog):
|
|||||||
def on_spiel_starten(self):
|
def on_spiel_starten(self):
|
||||||
dateiname = os.path.join(CONFIG["pfad_cloud"], "aktiv_{}".format(CONFIG["username"]))
|
dateiname = os.path.join(CONFIG["pfad_cloud"], "aktiv_{}".format(CONFIG["username"]))
|
||||||
with open(dateiname, "w") as file:
|
with open(dateiname, "w") as file:
|
||||||
file.write("")
|
file.write(f"{get_public_ip()}")
|
||||||
subprocess.call(CONFIG["pfad_game"])
|
subprocess.call(CONFIG["pfad_game"])
|
||||||
os.remove(dateiname)
|
os.remove(dateiname)
|
||||||
|
|
||||||
@@ -58,6 +72,7 @@ class EmpyrionLauncher(QtWidgets.QDialog):
|
|||||||
self.label_status_pfade.setText(self.text_status_pfade)
|
self.label_status_pfade.setText(self.text_status_pfade)
|
||||||
|
|
||||||
def cloud_lokal_verschieben(self):
|
def cloud_lokal_verschieben(self):
|
||||||
|
datei = ""
|
||||||
self.check_pfad()
|
self.check_pfad()
|
||||||
if self.status_pfade:
|
if self.status_pfade:
|
||||||
ordnerinhalt = os.listdir(CONFIG["pfad_cloud"])
|
ordnerinhalt = os.listdir(CONFIG["pfad_cloud"])
|
||||||
@@ -72,7 +87,7 @@ class EmpyrionLauncher(QtWidgets.QDialog):
|
|||||||
for datei in ordnerinhalt:
|
for datei in ordnerinhalt:
|
||||||
if datei.startswith("aktiv"):
|
if datei.startswith("aktiv"):
|
||||||
user = datei.split("_")[1]
|
user = datei.split("_")[1]
|
||||||
self.label_spiel_aktiv.setText("Spiel schon aktiv von {}".format(user))
|
self.label_spiel_aktiv.setText("Spiel schon aktiv von {} \n IP: {}".format(user, read_datei(datei)))
|
||||||
else:
|
else:
|
||||||
self.label_spiel_aktiv.setText("Kein Spiel aktiv")
|
self.label_spiel_aktiv.setText("Kein Spiel aktiv")
|
||||||
self.ui.button_spiel_starten.clicked.connect(self.on_spiel_starten)
|
self.ui.button_spiel_starten.clicked.connect(self.on_spiel_starten)
|
||||||
|
|||||||
Reference in New Issue
Block a user