ExecCommandDialog

  1from PySide6.QtWidgets import QDialog, QVBoxLayout, QLabel, QLineEdit, QPushButton, QTextEdit, QCheckBox, QMessageBox, QComboBox
  2from PySide6.QtCore import Qt, QProcess
  3
  4class ExecCommandDialog(QDialog):
  5    def __init__(self, parent=None):
  6        super().__init__(parent)
  7        self.setWindowTitle("Execute Command")
  8        self.setModal(True)
  9        self.setMinimumSize(400, 400)
 10
 11        self.layout = QVBoxLayout()
 12
 13        self.backend_input = QLineEdit(self)
 14        self.backend_input.setPlaceholderText("Enter the backend executable")
 15        self.backend_input.setText("backend.exe")
 16
 17        self.graph_file_input = QLineEdit(self)
 18        self.graph_file_input.setPlaceholderText("Enter the graph file")
 19        self.graph_file_input.setText("example.json")
 20
 21        self.keys_choice = QComboBox(self)
 22        self.keys_choice.addItem("GPT4o")
 23        self.keys_choice.addItem("Ollama")
 24        self.keys_choice.currentIndexChanged.connect(self.update_ui)
 25
 26        self.keys_input = QLineEdit(self)
 27        self.keys_input.setPlaceholderText("Enter the keys file")
 28        self.keys_input.setText("credentials.ini")
 29
 30        self.llm_input = QLineEdit(self)
 31        self.llm_input.setPlaceholderText("Enter the LLM model")
 32        self.llm_input.setText("phi3")
 33        self.llm_input.hide()  # Hide LLM input by default
 34
 35        self.log_to_file_checkbox = QCheckBox("Log to file", self)
 36        self.log_to_file_checkbox.setChecked(True)
 37
 38        self.run_button = QPushButton("Run", self)
 39        self.run_button.clicked.connect(self.run_command)
 40
 41        self.output_text = QTextEdit(self)
 42        self.output_text.setReadOnly(True)
 43
 44        self.layout.addWidget(QLabel("Backend:"))
 45        self.layout.addWidget(self.backend_input)
 46        self.layout.addWidget(QLabel("Graph File:"))
 47        self.layout.addWidget(self.graph_file_input)
 48        self.layout.addWidget(QLabel("Key Files:"))
 49        self.layout.addWidget(self.keys_choice)
 50        self.layout.addWidget(self.keys_input)
 51        self.layout.addWidget(self.llm_input)
 52        self.layout.addWidget(self.log_to_file_checkbox)
 53        self.layout.addWidget(self.run_button)
 54        self.layout.addWidget(QLabel("Output:"))
 55        self.layout.addWidget(self.output_text)
 56
 57        self.setLayout(self.layout)
 58
 59        self.process = QProcess(self)
 60        self.process.readyReadStandardOutput.connect(self.read_stdout)
 61        self.process.readyReadStandardError.connect(self.read_stderr)
 62        self.process.finished.connect(self.process_finished)
 63
 64    def update_ui(self):
 65        if self.keys_choice.currentText() == "Ollama":
 66            self.keys_input.hide()
 67            self.llm_input.show()
 68        else:
 69            self.keys_input.show()
 70            self.llm_input.hide()
 71
 72    def run_command(self):
 73        backend = self.backend_input.text().strip()
 74        graph_file = self.graph_file_input.text().strip()
 75        keys_choice = self.keys_choice.currentText()
 76        log_to_file = self.log_to_file_checkbox.isChecked()
 77
 78        if backend and graph_file:
 79            self.output_text.clear()
 80            if keys_choice == "Ollama":
 81                llm = self.llm_input.text().strip()
 82                if not llm:
 83                    QMessageBox.warning(self, "Warning", "Please enter the LLM model.")
 84                    return
 85                command = [backend, "--graph", graph_file, "--llm", llm]
 86            else:
 87                keys_file = self.keys_input.text().strip()
 88                if not keys_file:
 89                    QMessageBox.warning(self, "Warning", "Please enter the keys file.")
 90                    return
 91                command = [backend, "--graph", graph_file, "--keys", keys_file]
 92
 93            if log_to_file:
 94                command.append("--tee")
 95                command.append("output.log")
 96
 97            self.process.start(command[0], command[1:])
 98            if not self.process.waitForStarted():
 99                QMessageBox.critical(self, "Error", "Failed to start the command.")
100                self.output_text.append("Failed to start the command.")
101        else:
102            QMessageBox.warning(self, "Warning", "Please enter all required fields.")
103
104    def read_stdout(self):
105        data = self.process.readAllStandardOutput()
106        stdout = data.data().decode()
107        self.output_text.append(stdout)
108
109    def read_stderr(self):
110        data = self.process.readAllStandardError()
111        stderr = data.data().decode()
112        self.output_text.append(stderr)
113
114    def process_finished(self):
115        self.output_text.append("Process finished.")
116        exit_code = self.process.exitCode()
117        self.output_text.append(f"Process exited with code: {exit_code}")
class ExecCommandDialog(PySide6.QtWidgets.QDialog):
  5class ExecCommandDialog(QDialog):
  6    def __init__(self, parent=None):
  7        super().__init__(parent)
  8        self.setWindowTitle("Execute Command")
  9        self.setModal(True)
 10        self.setMinimumSize(400, 400)
 11
 12        self.layout = QVBoxLayout()
 13
 14        self.backend_input = QLineEdit(self)
 15        self.backend_input.setPlaceholderText("Enter the backend executable")
 16        self.backend_input.setText("backend.exe")
 17
 18        self.graph_file_input = QLineEdit(self)
 19        self.graph_file_input.setPlaceholderText("Enter the graph file")
 20        self.graph_file_input.setText("example.json")
 21
 22        self.keys_choice = QComboBox(self)
 23        self.keys_choice.addItem("GPT4o")
 24        self.keys_choice.addItem("Ollama")
 25        self.keys_choice.currentIndexChanged.connect(self.update_ui)
 26
 27        self.keys_input = QLineEdit(self)
 28        self.keys_input.setPlaceholderText("Enter the keys file")
 29        self.keys_input.setText("credentials.ini")
 30
 31        self.llm_input = QLineEdit(self)
 32        self.llm_input.setPlaceholderText("Enter the LLM model")
 33        self.llm_input.setText("phi3")
 34        self.llm_input.hide()  # Hide LLM input by default
 35
 36        self.log_to_file_checkbox = QCheckBox("Log to file", self)
 37        self.log_to_file_checkbox.setChecked(True)
 38
 39        self.run_button = QPushButton("Run", self)
 40        self.run_button.clicked.connect(self.run_command)
 41
 42        self.output_text = QTextEdit(self)
 43        self.output_text.setReadOnly(True)
 44
 45        self.layout.addWidget(QLabel("Backend:"))
 46        self.layout.addWidget(self.backend_input)
 47        self.layout.addWidget(QLabel("Graph File:"))
 48        self.layout.addWidget(self.graph_file_input)
 49        self.layout.addWidget(QLabel("Key Files:"))
 50        self.layout.addWidget(self.keys_choice)
 51        self.layout.addWidget(self.keys_input)
 52        self.layout.addWidget(self.llm_input)
 53        self.layout.addWidget(self.log_to_file_checkbox)
 54        self.layout.addWidget(self.run_button)
 55        self.layout.addWidget(QLabel("Output:"))
 56        self.layout.addWidget(self.output_text)
 57
 58        self.setLayout(self.layout)
 59
 60        self.process = QProcess(self)
 61        self.process.readyReadStandardOutput.connect(self.read_stdout)
 62        self.process.readyReadStandardError.connect(self.read_stderr)
 63        self.process.finished.connect(self.process_finished)
 64
 65    def update_ui(self):
 66        if self.keys_choice.currentText() == "Ollama":
 67            self.keys_input.hide()
 68            self.llm_input.show()
 69        else:
 70            self.keys_input.show()
 71            self.llm_input.hide()
 72
 73    def run_command(self):
 74        backend = self.backend_input.text().strip()
 75        graph_file = self.graph_file_input.text().strip()
 76        keys_choice = self.keys_choice.currentText()
 77        log_to_file = self.log_to_file_checkbox.isChecked()
 78
 79        if backend and graph_file:
 80            self.output_text.clear()
 81            if keys_choice == "Ollama":
 82                llm = self.llm_input.text().strip()
 83                if not llm:
 84                    QMessageBox.warning(self, "Warning", "Please enter the LLM model.")
 85                    return
 86                command = [backend, "--graph", graph_file, "--llm", llm]
 87            else:
 88                keys_file = self.keys_input.text().strip()
 89                if not keys_file:
 90                    QMessageBox.warning(self, "Warning", "Please enter the keys file.")
 91                    return
 92                command = [backend, "--graph", graph_file, "--keys", keys_file]
 93
 94            if log_to_file:
 95                command.append("--tee")
 96                command.append("output.log")
 97
 98            self.process.start(command[0], command[1:])
 99            if not self.process.waitForStarted():
100                QMessageBox.critical(self, "Error", "Failed to start the command.")
101                self.output_text.append("Failed to start the command.")
102        else:
103            QMessageBox.warning(self, "Warning", "Please enter all required fields.")
104
105    def read_stdout(self):
106        data = self.process.readAllStandardOutput()
107        stdout = data.data().decode()
108        self.output_text.append(stdout)
109
110    def read_stderr(self):
111        data = self.process.readAllStandardError()
112        stderr = data.data().decode()
113        self.output_text.append(stderr)
114
115    def process_finished(self):
116        self.output_text.append("Process finished.")
117        exit_code = self.process.exitCode()
118        self.output_text.append(f"Process exited with code: {exit_code}")

QDialog(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None

ExecCommandDialog(parent=None)
 6    def __init__(self, parent=None):
 7        super().__init__(parent)
 8        self.setWindowTitle("Execute Command")
 9        self.setModal(True)
10        self.setMinimumSize(400, 400)
11
12        self.layout = QVBoxLayout()
13
14        self.backend_input = QLineEdit(self)
15        self.backend_input.setPlaceholderText("Enter the backend executable")
16        self.backend_input.setText("backend.exe")
17
18        self.graph_file_input = QLineEdit(self)
19        self.graph_file_input.setPlaceholderText("Enter the graph file")
20        self.graph_file_input.setText("example.json")
21
22        self.keys_choice = QComboBox(self)
23        self.keys_choice.addItem("GPT4o")
24        self.keys_choice.addItem("Ollama")
25        self.keys_choice.currentIndexChanged.connect(self.update_ui)
26
27        self.keys_input = QLineEdit(self)
28        self.keys_input.setPlaceholderText("Enter the keys file")
29        self.keys_input.setText("credentials.ini")
30
31        self.llm_input = QLineEdit(self)
32        self.llm_input.setPlaceholderText("Enter the LLM model")
33        self.llm_input.setText("phi3")
34        self.llm_input.hide()  # Hide LLM input by default
35
36        self.log_to_file_checkbox = QCheckBox("Log to file", self)
37        self.log_to_file_checkbox.setChecked(True)
38
39        self.run_button = QPushButton("Run", self)
40        self.run_button.clicked.connect(self.run_command)
41
42        self.output_text = QTextEdit(self)
43        self.output_text.setReadOnly(True)
44
45        self.layout.addWidget(QLabel("Backend:"))
46        self.layout.addWidget(self.backend_input)
47        self.layout.addWidget(QLabel("Graph File:"))
48        self.layout.addWidget(self.graph_file_input)
49        self.layout.addWidget(QLabel("Key Files:"))
50        self.layout.addWidget(self.keys_choice)
51        self.layout.addWidget(self.keys_input)
52        self.layout.addWidget(self.llm_input)
53        self.layout.addWidget(self.log_to_file_checkbox)
54        self.layout.addWidget(self.run_button)
55        self.layout.addWidget(QLabel("Output:"))
56        self.layout.addWidget(self.output_text)
57
58        self.setLayout(self.layout)
59
60        self.process = QProcess(self)
61        self.process.readyReadStandardOutput.connect(self.read_stdout)
62        self.process.readyReadStandardError.connect(self.read_stderr)
63        self.process.finished.connect(self.process_finished)
def layout(unknown):
backend_input
graph_file_input
keys_choice
keys_input
llm_input
log_to_file_checkbox
run_button
output_text
process
def update_ui(self):
65    def update_ui(self):
66        if self.keys_choice.currentText() == "Ollama":
67            self.keys_input.hide()
68            self.llm_input.show()
69        else:
70            self.keys_input.show()
71            self.llm_input.hide()
def run_command(self):
 73    def run_command(self):
 74        backend = self.backend_input.text().strip()
 75        graph_file = self.graph_file_input.text().strip()
 76        keys_choice = self.keys_choice.currentText()
 77        log_to_file = self.log_to_file_checkbox.isChecked()
 78
 79        if backend and graph_file:
 80            self.output_text.clear()
 81            if keys_choice == "Ollama":
 82                llm = self.llm_input.text().strip()
 83                if not llm:
 84                    QMessageBox.warning(self, "Warning", "Please enter the LLM model.")
 85                    return
 86                command = [backend, "--graph", graph_file, "--llm", llm]
 87            else:
 88                keys_file = self.keys_input.text().strip()
 89                if not keys_file:
 90                    QMessageBox.warning(self, "Warning", "Please enter the keys file.")
 91                    return
 92                command = [backend, "--graph", graph_file, "--keys", keys_file]
 93
 94            if log_to_file:
 95                command.append("--tee")
 96                command.append("output.log")
 97
 98            self.process.start(command[0], command[1:])
 99            if not self.process.waitForStarted():
100                QMessageBox.critical(self, "Error", "Failed to start the command.")
101                self.output_text.append("Failed to start the command.")
102        else:
103            QMessageBox.warning(self, "Warning", "Please enter all required fields.")
def read_stdout(self):
105    def read_stdout(self):
106        data = self.process.readAllStandardOutput()
107        stdout = data.data().decode()
108        self.output_text.append(stdout)
def read_stderr(self):
110    def read_stderr(self):
111        data = self.process.readAllStandardError()
112        stderr = data.data().decode()
113        self.output_text.append(stderr)
def process_finished(self):
115    def process_finished(self):
116        self.output_text.append("Process finished.")
117        exit_code = self.process.exitCode()
118        self.output_text.append(f"Process exited with code: {exit_code}")
staticMetaObject = PySide6.QtCore.QMetaObject("ExecCommandDialog" inherits "QDialog": )
Inherited Members
PySide6.QtWidgets.QDialog
accept
adjustPosition
closeEvent
contextMenuEvent
done
eventFilter
exec
exec_
isSizeGripEnabled
keyPressEvent
minimumSizeHint
open
reject
resizeEvent
result
setModal
setResult
setSizeGripEnabled
setVisible
showEvent
sizeHint
DialogCode
finished
accepted
rejected
PySide6.QtWidgets.QWidget
acceptDrops
accessibleDescription
accessibleName
actionEvent
actions
activateWindow
addAction
addActions
adjustSize
autoFillBackground
backgroundRole
backingStore
baseSize
changeEvent
childAt
childrenRect
childrenRegion
clearFocus
clearMask
close
contentsMargins
contentsRect
contextMenuPolicy
create
createWinId
createWindowContainer
cursor
destroy
devType
dragEnterEvent
dragLeaveEvent
dragMoveEvent
dropEvent
effectiveWinId
ensurePolished
enterEvent
event
find
focusInEvent
focusNextChild
focusNextPrevChild
focusOutEvent
focusPolicy
focusPreviousChild
focusProxy
focusWidget
font
fontInfo
fontMetrics
foregroundRole
frameGeometry
frameSize
geometry
grab
grabGesture
grabKeyboard
grabMouse
grabShortcut
graphicsEffect
graphicsProxyWidget
hasFocus
hasHeightForWidth
hasMouseTracking
hasTabletTracking
height
heightForWidth
hide
hideEvent
initPainter
inputMethodEvent
inputMethodHints
inputMethodQuery
insertAction
insertActions
internalWinId
isActiveWindow
isAncestorOf
isEnabled
isEnabledTo
isFullScreen
isHidden
isLeftToRight
isMaximized
isMinimized
isModal
isRightToLeft
isTopLevel
isVisible
isVisibleTo
isWindow
isWindowModified
keyReleaseEvent
keyboardGrabber
layoutDirection
leaveEvent
locale
lower
mapFrom
mapFromGlobal
mapFromParent
mapTo
mapToGlobal
mapToParent
mask
maximumHeight
maximumSize
maximumWidth
metric
minimumHeight
minimumSize
minimumWidth
mouseDoubleClickEvent
mouseGrabber
mouseMoveEvent
mousePressEvent
mouseReleaseEvent
move
moveEvent
nativeEvent
nativeParentWidget
nextInFocusChain
normalGeometry
overrideWindowFlags
overrideWindowState
paintEngine
paintEvent
palette
parentWidget
pos
previousInFocusChain
raise_
rect
redirected
releaseKeyboard
releaseMouse
releaseShortcut
removeAction
render
repaint
resize
restoreGeometry
saveGeometry
screen
scroll
setAcceptDrops
setAccessibleDescription
setAccessibleName
setAttribute
setAutoFillBackground
setBackgroundRole
setBaseSize
setContentsMargins
setContextMenuPolicy
setCursor
setDisabled
setEnabled
setFixedHeight
setFixedSize
setFixedWidth
setFocus
setFocusPolicy
setFocusProxy
setFont
setForegroundRole
setGeometry
setGraphicsEffect
setHidden
setInputMethodHints
setLayout
setLayoutDirection
setLocale
setMask
setMaximumHeight
setMaximumSize
setMaximumWidth
setMinimumHeight
setMinimumSize
setMinimumWidth
setMouseTracking
setPalette
setParent
setScreen
setShortcutAutoRepeat
setShortcutEnabled
setSizeIncrement
setSizePolicy
setStatusTip
setStyle
setStyleSheet
setTabOrder
setTabletTracking
setToolTip
setToolTipDuration
setUpdatesEnabled
setWhatsThis
setWindowFilePath
setWindowFlag
setWindowFlags
setWindowIcon
setWindowIconText
setWindowModality
setWindowModified
setWindowOpacity
setWindowRole
setWindowState
setWindowTitle
sharedPainter
show
showFullScreen
showMaximized
showMinimized
showNormal
size
sizeIncrement
sizePolicy
stackUnder
statusTip
style
styleSheet
tabletEvent
testAttribute
toolTip
toolTipDuration
topLevelWidget
underMouse
ungrabGesture
unsetCursor
unsetLayoutDirection
unsetLocale
update
updateGeometry
updateMicroFocus
updatesEnabled
visibleRegion
whatsThis
wheelEvent
width
winId
window
windowFilePath
windowFlags
windowHandle
windowIcon
windowIconText
windowModality
windowOpacity
windowRole
windowState
windowTitle
windowType
x
y
RenderFlag
windowTitleChanged
windowIconChanged
windowIconTextChanged
customContextMenuRequested
PySide6.QtCore.QObject
blockSignals
childEvent
children
connect
connectNotify
customEvent
deleteLater
disconnect
disconnectNotify
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
emit
findChild
findChildren
inherits
installEventFilter
isQuickItemType
isSignalConnected
isWidgetType
isWindowType
killTimer
metaObject
moveToThread
objectName
parent
property
receivers
removeEventFilter
sender
senderSignalIndex
setObjectName
setProperty
signalsBlocked
startTimer
thread
timerEvent
tr
destroyed
objectNameChanged
PySide6.QtGui.QPaintDevice
colorCount
depth
devicePixelRatio
devicePixelRatioF
devicePixelRatioFScale
heightMM
logicalDpiX
logicalDpiY
paintingActive
physicalDpiX
physicalDpiY
widthMM
painters
PaintDeviceMetric