Moved server promt to main thread
This is also not a perfect or very pretty solution, especially as configparser is now a dependency. But this is still an improvement over how it was before, as this doesn't seem to cause crashes.
This commit is contained in:
parent
25f16fc561
commit
5f5341f96d
3 changed files with 41 additions and 30 deletions
|
@ -1,5 +1,6 @@
|
||||||
# pesterchum
|
# pesterchum
|
||||||
import os, shutil, sys, getopt
|
import os, shutil, sys, getopt
|
||||||
|
import configparser
|
||||||
if os.path.dirname(sys.argv[0]):
|
if os.path.dirname(sys.argv[0]):
|
||||||
os.chdir(os.path.dirname(sys.argv[0]))
|
os.chdir(os.path.dirname(sys.argv[0]))
|
||||||
import logging
|
import logging
|
||||||
|
@ -136,7 +137,6 @@ BOTNAMES.extend(CUSTOMBOTS)
|
||||||
_CONSOLE_ENV = AttrDict()
|
_CONSOLE_ENV = AttrDict()
|
||||||
_CONSOLE_ENV.PAPP = None
|
_CONSOLE_ENV.PAPP = None
|
||||||
|
|
||||||
|
|
||||||
class waitingMessageHolder(object):
|
class waitingMessageHolder(object):
|
||||||
def __init__(self, mainwindow, **msgfuncs):
|
def __init__(self, mainwindow, **msgfuncs):
|
||||||
self.mainwindow = mainwindow
|
self.mainwindow = mainwindow
|
||||||
|
@ -3043,6 +3043,38 @@ class MainProgram(QtCore.QObject):
|
||||||
|
|
||||||
options = self.oppts(sys.argv[1:])
|
options = self.oppts(sys.argv[1:])
|
||||||
|
|
||||||
|
# Choose a server by qt message box.
|
||||||
|
# Writes the result to server.ini
|
||||||
|
|
||||||
|
msgBox = QtGui.QMessageBox()
|
||||||
|
msgBox.setIcon(QtGui.QMessageBox.Information)
|
||||||
|
msgBox.setWindowTitle("Choose a server.")
|
||||||
|
msgBox.setText("Which server do you want to connect to?")
|
||||||
|
msgBox.addButton(QtGui.QPushButton("ghostDunk's server (Official)"), QtGui.QMessageBox.YesRole)
|
||||||
|
msgBox.addButton(QtGui.QPushButton("turntechCatnip's server"), QtGui.QMessageBox.NoRole)
|
||||||
|
msgBox.addButton(QtGui.QPushButton('kaliope.ddns.net'), QtGui.QMessageBox.RejectRole)
|
||||||
|
ret = msgBox.exec_()
|
||||||
|
reply = msgBox.buttonRole(msgBox.clickedButton())
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read('server.ini')
|
||||||
|
|
||||||
|
if (reply==QtGui.QMessageBox.YesRole):
|
||||||
|
print("Server is: irc.mindfang.org")
|
||||||
|
config['SERVER']['server'] = 'irc.mindfang.org'
|
||||||
|
if (reply==QtGui.QMessageBox.NoRole):
|
||||||
|
print("Server is: 178.84.124.125")
|
||||||
|
config['SERVER']['server'] = '178.84.124.125'
|
||||||
|
if (reply==QtGui.QMessageBox.RejectRole):
|
||||||
|
print("Server is: kaliope.ddns.net")
|
||||||
|
config['SERVER']['server'] = 'kaliope.ddns.net'
|
||||||
|
|
||||||
|
#Write result to server.ini
|
||||||
|
with open('server.ini', 'w') as configfile:
|
||||||
|
config.write(configfile)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def doSoundInit():
|
def doSoundInit():
|
||||||
# TODO: Make this more uniform, adapt it into a general function.
|
# TODO: Make this more uniform, adapt it into a general function.
|
||||||
if pygame and pygame.mixer:
|
if pygame and pygame.mixer:
|
||||||
|
|
35
profile.py
35
profile.py
|
@ -14,6 +14,8 @@ from mood import Mood
|
||||||
from dataobjs import PesterProfile, pesterQuirk, pesterQuirks
|
from dataobjs import PesterProfile, pesterQuirk, pesterQuirks
|
||||||
from parsetools import convertTags, addTimeInitial, themeChecker, ThemeException
|
from parsetools import convertTags, addTimeInitial, themeChecker, ThemeException
|
||||||
|
|
||||||
|
import configparser # For loading server.ini
|
||||||
|
|
||||||
_datadir = ostools.getDataDir()
|
_datadir = ostools.getDataDir()
|
||||||
|
|
||||||
class PesterLog(object):
|
class PesterLog(object):
|
||||||
|
@ -285,35 +287,10 @@ class userConfig(object):
|
||||||
def server(self):
|
def server(self):
|
||||||
if hasattr(self.parent, 'serverOverride'):
|
if hasattr(self.parent, 'serverOverride'):
|
||||||
return self.parent.serverOverride
|
return self.parent.serverOverride
|
||||||
# Okay, so I tried to use qt to promt the user to choose a server via a message box.
|
# Get chosen server from server.ini
|
||||||
# It seems to ...work... but I know that this isn't the proper way to implement something like this at all.
|
config = configparser.ConfigParser()
|
||||||
# But, uh, I have no clue how to properly use qt.
|
config.read('server.ini')
|
||||||
# If anyone knows how to actually implement something like this please feel free to fix this.
|
return self.config.get('server', config['SERVER']['server'])
|
||||||
# HOPEFULLY this is a temporary solution
|
|
||||||
|
|
||||||
msgBox = QtGui.QMessageBox()
|
|
||||||
msgBox.setIcon(QtGui.QMessageBox.Information)
|
|
||||||
msgBox.setWindowTitle("Choose a server.")
|
|
||||||
msgBox.setText("Which server do you want to connect to?")
|
|
||||||
msgBox.addButton(QtGui.QPushButton("ghostDunk's server (Official)"), QtGui.QMessageBox.YesRole)
|
|
||||||
msgBox.addButton(QtGui.QPushButton("turntechCatnip's server"), QtGui.QMessageBox.NoRole)
|
|
||||||
msgBox.addButton(QtGui.QPushButton('kaliope.ddns.net'), QtGui.QMessageBox.RejectRole)
|
|
||||||
ret = msgBox.exec_()
|
|
||||||
#pressed_button = msgBox.clickedButton()
|
|
||||||
reply = msgBox.buttonRole(msgBox.clickedButton())
|
|
||||||
|
|
||||||
if (reply==QtGui.QMessageBox.YesRole):
|
|
||||||
print("Server is: irc.mindfang.org")
|
|
||||||
return self.config.get('server', 'irc.mindfang.org')
|
|
||||||
if (reply==QtGui.QMessageBox.NoRole):
|
|
||||||
print("Server is: 178.84.124.125")
|
|
||||||
return self.config.get('server', '178.84.124.125')
|
|
||||||
if (reply==QtGui.QMessageBox.RejectRole):
|
|
||||||
print("Server is: kaliope.ddns.net")
|
|
||||||
return self.config.get('server', 'kaliope.ddns.net')
|
|
||||||
|
|
||||||
#print(reply)
|
|
||||||
#return self.config.get('server', 'irc.mindfang.org')
|
|
||||||
def port(self):
|
def port(self):
|
||||||
if hasattr(self.parent, 'portOverride'):
|
if hasattr(self.parent, 'portOverride'):
|
||||||
return self.parent.portOverride
|
return self.parent.portOverride
|
||||||
|
|
2
server.ini
Normal file
2
server.ini
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[SERVER]
|
||||||
|
server = 178.84.124.125
|
Loading…
Reference in a new issue