Skip to content

Commit

Permalink
Pool Server Configurator implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Trippen committed Apr 2, 2019
1 parent ba2d2cb commit ae6d1ee
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 2 deletions.
6 changes: 6 additions & 0 deletions start/AFANASY/afpoolserverconfig.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rem Name=Configure Pool Server
rem Icon=afanasy.png
rem Separator
call %0\..\_setup.cmd

"%CGRU_PYTHONEXE%" "%CGRU_LOCATION%\utilities\poolssupport\poolserver\configurator.py" %*
File renamed without changes.
Binary file not shown.
4 changes: 2 additions & 2 deletions utilities/poolssupport/poolserver/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"max_clients": 32,
"port": 9999,
"ip": ""
"ip": "",
"port": 9999
}
93 changes: 93 additions & 0 deletions utilities/poolssupport/poolserver/configurator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Encoding: UTF-8
# Author: Laurence Trippen
# Date: 02.04.2019
# E-Mail: [email protected]
# Program: Afanasy Pool Server Configurator - Main

import os
import sys
import cgruutils

from Qt import QtCore, QtGui, QtWidgets
from config import Config

# MainWindow class
class MainWindow(QtWidgets.QWidget):
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setFixedSize(340, 125)
self.initUI()
self.load()

# UI initialization
def initUI(self):
# Window Title
self.setWindowTitle('Pool Server Configurator CGRU %s' %
os.getenv('CGRU_VERSION', ''))

# Window icon
iconpath = cgruutils.getIconFileName('afanasy')
if iconpath is not None:
self.setWindowIcon(QtGui.QIcon(iconpath))

self.ipLabel = QtWidgets.QLabel("Binding IP:")
self.ipLineEdit = QtGui.QLineEdit()
self.ipLineEdit.setPlaceholderText("If empty localhost is set.")
self.ipLayout = QtWidgets.QHBoxLayout()
self.ipLayout.addWidget(self.ipLabel)
self.ipLayout.addWidget(self.ipLineEdit)

self.portLabel = QtWidgets.QLabel("Port:")
self.portSpinBox = QtGui.QSpinBox()
self.portSpinBox.setMinimum(0)
self.portSpinBox.setMaximum(65535)
self.portLayout = QtWidgets.QHBoxLayout()
self.portLayout.addWidget(self.portLabel)
self.portLayout.addWidget(self.portSpinBox)

self.maxClientsLabel = QtWidgets.QLabel("Max. Clients: (Renderfarm clients.)")
self.maxClientsSpinBox = QtGui.QSpinBox()
self.maxClientsSpinBox.setMinimum(0)
self.maxClientsSpinBox.setMaximum(100000)
self.maxClientsLayout = QtWidgets.QHBoxLayout()
self.maxClientsLayout.addWidget(self.maxClientsLabel)
self.maxClientsLayout.addWidget(self.maxClientsSpinBox)

self.saveButton = QtWidgets.QPushButton("Save")
self.saveButton.clicked.connect(self.save)

# Top Root Layout
self.topLayout = QtWidgets.QVBoxLayout(self)
self.topLayout.addLayout(self.ipLayout)
self.topLayout.addLayout(self.portLayout)
self.topLayout.addLayout(self.maxClientsLayout)
self.topLayout.addWidget(self.saveButton)

# Loads config
def load(self):
Config.check()
Config.load()
self.ipLineEdit.setText(Config.ip)
self.portSpinBox.setValue(Config.port)
self.maxClientsSpinBox.setValue(Config.max_clients)

# Saves config
def save(self):
Config.save({
"ip":self.ipLineEdit.text(),
"port":self.portSpinBox.value(),
"max_clients":self.maxClientsSpinBox.value()
})
self.close()

if __name__ == "__main__":
if "CGRU_LOCATION" in os.environ:
print("CGRU_LOCATION=" + os.environ['CGRU_LOCATION'])
else:
print("CGRU_LOCATION is not set!")
sys.exit()

app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
3 changes: 3 additions & 0 deletions utilities/poolssupport/poolserver/start/configurator.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

call %CGRU_LOCATION%\start\AFANASY\afpoolserverconfig.cmd

0 comments on commit ae6d1ee

Please sign in to comment.