Skip to content

Commit 4b6b0f1

Browse files
author
Sebastian
committed
initialized configuration from console
1 parent 2cc9aaa commit 4b6b0f1

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

RTOC/RTOC.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -732,22 +732,22 @@ def setLanguage(app):
732732

733733

734734
def main():
735-
opts, args = getopt.getopt(sys.argv[1:], "hspr:", ["remote="])
735+
opts, args = getopt.getopt(sys.argv[1:], "hs:p:r:c:", ["server=","remote=","port=",'config='])
736736
if len(opts) == 0:
737737
startRTOC()
738738
else:
739739
for opt, arg in opts:
740-
if opt == '-p':
740+
if opt in ('-p', '--port'):
741741
port = int(arg)
742742
break
743743
else:
744744
port = 5050
745745
for opt, arg in opts:
746746
if opt == '-h':
747747
print(
748-
'RTOC.py [-h, -s] [-r <Remoteadress>]\n -h: Hilfe\n-s: TCP-Server ohne GUI\n-r <Remoteadresse>: TCP-Client zu RTOC-Server\n-p: Starte TCP-Server auf anderem Port (Standart: 5050)')
749-
sys.exit()
750-
elif opt == '-s':
748+
'RTOC.py [-h, -s] [-r <Remoteadress>]\n -h: Hilfe\n-s (--server) [COMMAND]: TCP-Server ohne GUI\n\t- start: Starts the RTOC-daemon\n\t- stop: Stops the RTOC-daemon\n\t- restart: Restarts the RTOC-daemon\n-r (--remote) <Remoteadresse>: TCP-Client zu RTOC-Server\n-p (--port): Starte TCP-Server auf anderem Port (Standart: 5050)\n-c (--config): Configure RTOC')
749+
sys.exit(0)
750+
elif opt in ('-s','--server'):
751751
# logger = RTLogger.RTLogger(True, port)
752752
# #runInBackground()
753753
# while logger.run:
@@ -763,19 +763,25 @@ def main():
763763
daemon.start()
764764
else:
765765
print('Unknown server command: '+str(command)+'\nUse "start", "stop" or "restart"')
766+
sys.exit(1)
766767
elif opt in ("-r", "--remote"):
767768
remotepath = arg
768769
startRemoteRTOC(remotepath)
769770
sys.exit(0)
770-
startRTOC(None, port)
771+
elif opt in ('-c','--config'):
772+
configureRTOC(arg)
773+
#startRTOC(None, port)
771774

772775

773-
def runInBackground():
774-
app = QtWidgets.QApplication(sys.argv)
775-
myapp = RTOC_TCP()
776-
app, myapp = setStyleSheet(app, myapp)
776+
def configureRTOC(arg):
777+
pass
777778

778-
app.exec_()
779+
# def runInBackground():
780+
# app = QtWidgets.QApplication(sys.argv)
781+
# myapp = RTOC_TCP()
782+
# app, myapp = setStyleSheet(app, myapp)
783+
#
784+
# app.exec_()
779785

780786

781787
def startRemoteRTOC(remotepath):

RTOC/__main__.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run(self):
2828

2929

3030
def main():
31-
opts, args = getopt.getopt(sys.argv[1:], "hsp:r:", ["remote=","port="])
31+
opts, args = getopt.getopt(sys.argv[1:], "hs:p:r:c:", ["server=","remote=","port=",'config='])
3232
if len(opts) == 0:
3333
startRTOC()
3434
else:
@@ -41,9 +41,9 @@ def main():
4141
for opt, arg in opts:
4242
if opt == '-h':
4343
print(
44-
'RTOC.py [-h, -s] [-r <Remoteadress>]\n -h: Hilfe\n-s: TCP-Server ohne GUI\n-r <Remoteadresse>: TCP-Client zu RTOC-Server\n-p: Starte TCP-Server auf anderem Port (Standart: 5050)')
45-
sys.exit()
46-
elif opt == '-s':
44+
'RTOC.py [-h, -s] [-r <Remoteadress>]\n -h: Hilfe\n-s (--server) [COMMAND]: TCP-Server ohne GUI\n\t- start: Starts the RTOC-daemon\n\t- stop: Stops the RTOC-daemon\n\t- restart: Restarts the RTOC-daemon\n-r (--remote) <Remoteadresse>: TCP-Client zu RTOC-Server\n-p (--port): Starte TCP-Server auf anderem Port (Standart: 5050)\n-c (--config): Configure RTOC')
45+
sys.exit(0)
46+
elif opt in ('-s','--server'):
4747
command = arg
4848
daemon = RTOCDaemon('/tmp/RTOCDaemon.pid')
4949
if command == 'stop':
@@ -54,13 +54,17 @@ def main():
5454
daemon.start()
5555
else:
5656
print('Unknown server command: '+str(command)+'\nUse "start", "stop" or "restart"')
57-
57+
sys.exit(1)
58+
elif opt in ('-c','--config'):
59+
configureRTOC(arg)
5860
elif opt in ("-r", "--remote"):
5961
remotepath = arg
6062
startRemoteRTOC(remotepath)
6163
sys.exit(0)
62-
startRTOC(None, port)
64+
#startRTOC(None, port)
6365

66+
def configureRTOC(arg):
67+
pass
6468

6569
def setStyleSheet(app, myapp):
6670
if os.name == 'posix':
@@ -138,12 +142,12 @@ def setLanguage(app):
138142
# compile translationfile: % lrelease-qt5 lang/de_de.ts
139143
# use self.tr("TEXT TO TRANSLATE") in the code
140144

141-
def runInBackground():
142-
app = QtWidgets.QApplication(sys.argv)
143-
myapp = RTOC_TCP()
144-
app, myapp = setStyleSheet(app, myapp)
145-
146-
app.exec_()
145+
# def runInBackground():
146+
# app = QtWidgets.QApplication(sys.argv)
147+
# myapp = RTOC_TCP()
148+
# app, myapp = setStyleSheet(app, myapp)
149+
#
150+
# app.exec_()
147151

148152

149153
def startRemoteRTOC(remotepath):

0 commit comments

Comments
 (0)