Fix not responding error

This commit is contained in:
leha-code 2022-03-14 09:18:58 -04:00
parent de26e4a87e
commit c908617c7e
No known key found for this signature in database
GPG Key ID: 15227A6455DDF7EE
2 changed files with 97 additions and 79 deletions

View File

@ -4,8 +4,7 @@ import os
def get_features_list(path_: str) -> list: def get_features_list(path_: str) -> list:
features = subprocess.run( features = subprocess.run(
[path_, "--print-available-feature-flags"], [path_, "--print-available-feature-flags"], stdout=subprocess.PIPE
stdout=subprocess.PIPE,
).stdout.decode("utf-8") ).stdout.decode("utf-8")
features = features.split("\n") features = features.split("\n")
returnlist = list() returnlist = list()
@ -21,8 +20,7 @@ def get_features_list(path_: str) -> list:
def get_features_dict(path_: str) -> dict: def get_features_dict(path_: str) -> dict:
features = subprocess.run( features = subprocess.run(
[path_, "--print-available-feature-flags"], [path_, "--print-available-feature-flags"], stdout=subprocess.PIPE
stdout=subprocess.PIPE,
).stdout.decode("utf-8") ).stdout.decode("utf-8")
features = features.split("\n") features = features.split("\n")
returndict = dict() returndict = dict()
@ -65,6 +63,4 @@ def set_options(env, options: dict):
def run(env, path_: str): def run(env, path_: str):
return subprocess.Popen( return subprocess.Popen([path_], env=env, preexec_fn=os.setsid)
[path_], env=env, preexec_fn=os.setsid
).wait()

View File

@ -64,6 +64,7 @@ if not os.path.exists(f"/home/{USER}/.planet-launcher/mods"):
# else: # else:
# TODO: Add a tab with a button to import features from gMCPIL # TODO: Add a tab with a button to import features from gMCPIL
class ConfigPluto(QDialog): class ConfigPluto(QDialog):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
@ -72,7 +73,9 @@ class ConfigPluto(QDialog):
layout = QVBoxLayout() layout = QVBoxLayout()
titlelayout = QGridLayout() titlelayout = QGridLayout()
logopixmap = QPixmap(f"{absolute_path}/assets/logo512.png").scaled(100, 100, Qt.KeepAspectRatio) logopixmap = QPixmap(f"{absolute_path}/assets/logo512.png").scaled(
100, 100, Qt.KeepAspectRatio
)
namelabel = QLabel("Pluto Wizard") namelabel = QLabel("Pluto Wizard")
logolabel = QLabel() logolabel = QLabel()
@ -90,7 +93,9 @@ class ConfigPluto(QDialog):
titlewidget = QWidget() titlewidget = QWidget()
titlewidget.setLayout(titlelayout) titlewidget.setLayout(titlelayout)
info_label = QLabel("Please select the executable you downloaded.\nIf you installed a DEB, please select the \"Link\" option") info_label = QLabel(
'Please select the executable you downloaded.\nIf you installed a DEB, please select the "Link" option'
)
self.executable_btn = QPushButton("Select executable") self.executable_btn = QPushButton("Select executable")
self.executable_btn.clicked.connect(self.get_appimage) self.executable_btn.clicked.connect(self.get_appimage)
@ -123,10 +128,16 @@ class ConfigPluto(QDialog):
def get_appimage(self): def get_appimage(self):
self.hide() self.hide()
self.filename = QFileDialog.getOpenFileName(self, 'Select executable', '/',"Executable files (*.AppImage *.bin *.sh *)") self.filename = QFileDialog.getOpenFileName(
self, "Select executable", "/", "Executable files (*.AppImage *.bin *.sh *)"
)
def link_appimage(self): def link_appimage(self):
self.hide() self.hide()
os.symlink("/usr/bin/minecraft-pi-reborn-client", f"/home/{USER}/.planet-launcher/minecraft.AppImage") os.symlink(
"/usr/bin/minecraft-pi-reborn-client",
f"/home/{USER}/.planet-launcher/minecraft.AppImage",
)
self.filename = list() self.filename = list()
self.filename.append(False) self.filename.append(False)
@ -143,7 +154,12 @@ class Planet(QMainWindow):
try: try:
RPC = pypresence.Presence(787496148763541505) RPC = pypresence.Presence(787496148763541505)
RPC.connect() RPC.connect()
RPC.update(state="Launched with Planet Launcher", details="Minecraft Pi Edition: Reborn", large_image="logo", small_image=random.choice(["heart", "portal", "multiplayer", "pi"])) RPC.update(
state="Launched with Planet Launcher",
details="Minecraft Pi Edition: Reborn",
large_image="logo",
small_image=random.choice(["heart", "portal", "multiplayer", "pi"]),
)
except: except:
print("Unable to initalize Discord RPC. Skipping.") print("Unable to initalize Discord RPC. Skipping.")
@ -151,7 +167,9 @@ class Planet(QMainWindow):
self.conf = { self.conf = {
"username": "StevePi", "username": "StevePi",
"options": launcher.get_features_dict(f"/home/{USER}/.planet-launcher/minecraft.AppImage"), "options": launcher.get_features_dict(
f"/home/{USER}/.planet-launcher/minecraft.AppImage"
),
"hidelauncher": True, "hidelauncher": True,
"profile": "Modded MCPE", "profile": "Modded MCPE",
"render_distance": "Short", "render_distance": "Short",
@ -165,7 +183,6 @@ class Planet(QMainWindow):
with open(f"/home/{USER}/.planet-launcher/config.json") as file: with open(f"/home/{USER}/.planet-launcher/config.json") as file:
self.conf = json.loads(file.read()) self.conf = json.loads(file.read())
self.setWindowTitle("Planet") self.setWindowTitle("Planet")
self.setWindowIcon(QIcon(f"{absolute_path}/assets/logo512.png")) self.setWindowIcon(QIcon(f"{absolute_path}/assets/logo512.png"))
@ -179,9 +196,11 @@ class Planet(QMainWindow):
features_tab = tabs.addTab(self.features_tab(), "Features") features_tab = tabs.addTab(self.features_tab(), "Features")
tabs.setTabIcon(features_tab, QIcon(f"{absolute_path}/assets/heart512.png")) tabs.setTabIcon(features_tab, QIcon(f"{absolute_path}/assets/heart512.png"))
servers_tab = tabs.addTab(self.servers_tab(), "Servers") servers_tab = tabs.addTab(self.servers_tab(), "Servers")
tabs.setTabIcon(servers_tab, QIcon(f"{absolute_path}/assets/multiplayer512.png")) tabs.setTabIcon(
#mods_tab = tabs.addTab(self.custom_mods_tab(), "Mods") servers_tab, QIcon(f"{absolute_path}/assets/multiplayer512.png")
#tabs.setTabIcon(mods_tab, QIcon(f"{absolute_path}/assets/portal512.png")) )
# mods_tab = tabs.addTab(self.custom_mods_tab(), "Mods")
# tabs.setTabIcon(mods_tab, QIcon(f"{absolute_path}/assets/portal512.png"))
changelog_tab = tabs.addTab(self.changelog_tab(), "Changelog") changelog_tab = tabs.addTab(self.changelog_tab(), "Changelog")
tabs.setTabIcon(changelog_tab, QIcon(f"{absolute_path}/assets/pi512.png")) tabs.setTabIcon(changelog_tab, QIcon(f"{absolute_path}/assets/pi512.png"))
@ -208,7 +227,9 @@ class Planet(QMainWindow):
titlelayout = QGridLayout() titlelayout = QGridLayout()
logopixmap = QPixmap(f"{absolute_path}/assets/logo512.png").scaled(100, 100, Qt.KeepAspectRatio) logopixmap = QPixmap(f"{absolute_path}/assets/logo512.png").scaled(
100, 100, Qt.KeepAspectRatio
)
logolabel = QLabel() logolabel = QLabel()
logolabel.setPixmap(logopixmap) logolabel.setPixmap(logopixmap)
@ -293,7 +314,9 @@ class Planet(QMainWindow):
layout = QVBoxLayout() layout = QVBoxLayout()
self.features = dict() self.features = dict()
default_features = launcher.get_features_dict(f"/home/{USER}/.planet-launcher/minecraft.AppImage") default_features = launcher.get_features_dict(
f"/home/{USER}/.planet-launcher/minecraft.AppImage"
)
for feature in default_features: for feature in default_features:
checkbox = QCheckBox(feature) checkbox = QCheckBox(feature)
@ -337,7 +360,9 @@ class Planet(QMainWindow):
with open(f"/home/{USER}/.minecraft-pi/servers.txt") as servers: with open(f"/home/{USER}/.minecraft-pi/servers.txt") as servers:
self.serversedit.setPlainText(servers.read()) self.serversedit.setPlainText(servers.read())
infolabel = QLabel("Servers are stored in the format of <font color=\"gold\">IP: </font><font color=\"blue\">Port</font>") infolabel = QLabel(
'Servers are stored in the format of <font color="gold">IP: </font><font color="blue">Port</font>'
)
layout.addWidget(self.serversedit, 0, 0) layout.addWidget(self.serversedit, 0, 0)
layout.addWidget(infolabel, 6, 0) layout.addWidget(infolabel, 6, 0)
@ -375,11 +400,7 @@ class Planet(QMainWindow):
def changelog_tab(self): def changelog_tab(self):
web = QWebView() web = QWebView()
web.load( web.load(QUrl().fromLocalFile(f"{absolute_path}/assets/changelog.html"))
QUrl().fromLocalFile(
f"{absolute_path}/assets/changelog.html"
)
)
return web return web
@ -411,9 +432,12 @@ class Planet(QMainWindow):
self.env, self.distancebox.currentText() self.env, self.distancebox.currentText()
) )
print(self.env)
if self.showlauncher.isChecked() == True: if self.showlauncher.isChecked() == True:
self.hide() self.hide()
launcher.run(
self.env, f"/home/{USER}/.planet-launcher/minecraft.AppImage"
).wait()
else:
launcher.run(self.env, f"/home/{USER}/.planet-launcher/minecraft.AppImage") launcher.run(self.env, f"/home/{USER}/.planet-launcher/minecraft.AppImage")
self.show() self.show()
@ -425,25 +449,23 @@ if __name__ == "__main__":
app = QApplication(sys.argv) app = QApplication(sys.argv)
app.setPalette(qdarktheme.load_palette("dark")) app.setPalette(qdarktheme.load_palette("dark"))
if not os.path.exists(f"/home/{USER}/.planet-launcher/minecraft.AppImage"): if not os.path.exists(f"/home/{USER}/.planet-launcher/minecraft.AppImage"):
pluto = ConfigPluto() pluto = ConfigPluto()
pluto.show() pluto.show()
pluto.exec() pluto.exec()
if pluto.filename[0] == '': if pluto.filename[0] == "":
sys.exit(-1) sys.exit(-1)
elif pluto.filename[0] == False: elif pluto.filename[0] == False:
print("Using /usr/bin as an executable.") print("Using /usr/bin as an executable.")
else: else:
with open(pluto.filename[0], "rb") as appimage: with open(pluto.filename[0], "rb") as appimage:
with open(f"/home/{USER}/.planet-launcher/minecraft.AppImage", "wb") as out: with open(
f"/home/{USER}/.planet-launcher/minecraft.AppImage", "wb"
) as out:
out.write(appimage.read()) out.write(appimage.read())
os.chmod(f"/home/{USER}/.planet-launcher/minecraft.AppImage", 0o777) os.chmod(f"/home/{USER}/.planet-launcher/minecraft.AppImage", 0o777)
window = Planet() window = Planet()
window.show() window.show()
app.exec() app.exec()