Added JSON file to manually set server.

This commit is contained in:
BuildTools 2021-02-22 17:09:40 +01:00
parent 78666ce904
commit 9c9a366355
3 changed files with 28 additions and 33 deletions

View file

@ -13,6 +13,10 @@ import random
import re import re
from time import time from time import time
import threading, Queue import threading, Queue
try:
import json
except:
pass
try: try:
from pnc.attrdict import AttrDict from pnc.attrdict import AttrDict
except ImportError: except ImportError:
@ -3052,35 +3056,27 @@ 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("Please choose a server")
#msgBox.setText("Which server do you want to connect to?")
#msgBox.addButton(QtGui.QPushButton("irc.mindfang.org (Official)"), QtGui.QMessageBox.YesRole)
#msgBox.addButton(QtGui.QPushButton("pesterchum.xyz (Unofficial)"), QtGui.QMessageBox.NoRole)
# msgBox.addButton(QtGui.QPushButton('kaliope.ddns.net (Unofficial)'), QtGui.QMessageBox.RejectRole)
#ret = msgBox.exec_()
#reply = msgBox.buttonRole(msgBox.clickedButton())
# Since there's currently no other working servers, all of this is commented out for now.
# Tries to load the server to connect to from server.json.
# If it fails, create json file with default of pesterchum.xyz & connect to pesterchum.xyz
try:
with open("server.json", "r") as server_file:
read_file = server_file.read()
server_file.close()
server_obj = json.loads(read_file)
self.server = str(server_obj['server'])
except:
try:
with open("server.json", "w") as server_file:
json_server_file = {
"server": "pesterchum.xyz",
}
server_file.write(json.dumps(json_server_file, indent = 4) )
server_file.close()
except:
pass
self.server = "pesterchum.xyz" self.server = "pesterchum.xyz"
print("Server is: pesterchum.xyz") print("Server is: " + self.server)
#if (reply==QtGui.QMessageBox.YesRole):
# print("Server is: irc.mindfang.org")
# self.server = "irc.mindfang.org"
#if (reply==QtGui.QMessageBox.NoRole):
# print("Server is: pesterchum.xyz")
# self.server = "pesterchum.xyz"
#if (reply==QtGui.QMessageBox.RejectRole):
# print("Server is: kaliope.ddns.net")
# self.server = "kaliope.ddns.net"
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.

3
server.json Normal file
View file

@ -0,0 +1,3 @@
{
"server": "pesterchum.xyz"
}

View file

@ -3,10 +3,6 @@ from cx_Freeze import setup, Executable
import sys import sys
import os import os
import shutil import shutil
import requests
import urllib
import PyQt4
from Queue import *
if sys.platform == "win32": if sys.platform == "win32":
base = "Win32GUI" base = "Win32GUI"
@ -21,7 +17,7 @@ build_exe_options = {
'collections._locale', 'collections._locale',
'collections._struct', 'collections._struct',
'collections.array', 'collections.array',
'collections._weakref'], # Not excluding these is the only way I could get it to build while using configparser. I don't know why though. 'collections._weakref'],
} }
setup( setup(