mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-04-18 08:40:18 +00:00
fix: use subprocess
instead of os.popen
for andreal calling
This commit is contained in:
parent
bce48a03a7
commit
de8c5d28a7
@ -2,6 +2,7 @@ import base64
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from PySide6.QtCore import QObject, QProcess, QRunnable, QThreadPool, Signal
|
from PySide6.QtCore import QObject, QProcess, QRunnable, QThreadPool, Signal
|
||||||
|
|
||||||
@ -24,7 +25,12 @@ class AndrealExecuteRunnable(QRunnable):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
result = os.popen(f"{self.executePath} {' '.join(self.arguments)}").read()
|
subp = subprocess.run(
|
||||||
|
[self.executePath, *self.arguments],
|
||||||
|
capture_output=True,
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
result = subp.stdout
|
||||||
b64Result = [s for s in result.split("\n") if s]
|
b64Result = [s for s in result.split("\n") if s]
|
||||||
imageBytes = base64.b64decode(
|
imageBytes = base64.b64decode(
|
||||||
re.sub(r"data:image/.*;base64,", "", b64Result[-1])
|
re.sub(r"data:image/.*;base64,", "", b64Result[-1])
|
||||||
|
@ -180,19 +180,20 @@ class TabTools_Andreal(Ui_TabTools_Andreal, QWidget):
|
|||||||
|
|
||||||
arguments = [
|
arguments = [
|
||||||
str(self.imageType()),
|
str(self.imageType()),
|
||||||
f'--json-file="{jsonFile}"',
|
"--json-file",
|
||||||
f"--img-version={self.imageVersion()}",
|
jsonFile,
|
||||||
|
"--img-version",
|
||||||
|
str(self.imageVersion()),
|
||||||
]
|
]
|
||||||
if self.andrealFolderSelector.selectedFiles():
|
if self.andrealFolderSelector.selectedFiles():
|
||||||
arguments.append(
|
arguments.append("--path")
|
||||||
f'--path="{self.andrealFolderSelector.selectedFiles()[0]}"'
|
arguments.append(self.andrealFolderSelector.selectedFiles()[0])
|
||||||
)
|
|
||||||
if preview:
|
if preview:
|
||||||
arguments.extend(["--img-format=jpg", "--img-quality=20"])
|
arguments.extend(["--img-format", "jpg", "--img-quality", "20"])
|
||||||
else:
|
else:
|
||||||
arguments.append(f"--img-format={self.imageFormat()}")
|
arguments.extend(["--img-format", self.imageFormat()])
|
||||||
if self.imageFormat() == "jpg":
|
if self.imageFormat() == "jpg":
|
||||||
arguments.append(f"--img-quality={self.jpgQualitySpinBox.value()}")
|
arguments.extend(["--img-quality", str(self.jpgQualitySpinBox.value())])
|
||||||
return arguments
|
return arguments
|
||||||
|
|
||||||
def getAndrealJsonContent(self):
|
def getAndrealJsonContent(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user