Preparation for building :)
This commit is contained in:
parent
8ab4c3495f
commit
90be0894fb
6 changed files with 41 additions and 119 deletions
|
@ -1,76 +0,0 @@
|
|||
import os, socket
|
||||
|
||||
class TwmnError(Exception):
|
||||
UNWN_ERR = -1
|
||||
NO_TWMND = -2
|
||||
NO_CONF = -3
|
||||
def __init__(self, code):
|
||||
self.code = code
|
||||
def __str__(self):
|
||||
if self.code == TwmnError.NO_TWMND:
|
||||
return "Unable to connect to twmnd"
|
||||
elif self.code == TwmnError.NO_CONF:
|
||||
return "Could not find twmn configuration file"
|
||||
else:
|
||||
return "Unknown twmn error"
|
||||
|
||||
|
||||
def confExists():
|
||||
try:
|
||||
from xdg import BaseDirectory
|
||||
return os.path.join(BaseDirectory.xdg_config_home,"twmn/twmn.conf")
|
||||
except:
|
||||
return False
|
||||
|
||||
def init(host="127.0.0.1", port=None):
|
||||
if not port:
|
||||
port = 9797
|
||||
try:
|
||||
fn = confExists()
|
||||
if not fn:
|
||||
return False
|
||||
with open(fn) as f:
|
||||
for line in f.readlines():
|
||||
if line.startswith("port=") and \
|
||||
line[5:-1].isdigit():
|
||||
port = int(line[5:-1])
|
||||
break
|
||||
except IOError:
|
||||
raise TwmnError(TwmnError.NO_CONF)
|
||||
if type(port) == type(str()):
|
||||
port = int(port)
|
||||
global s
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.connect((host, port))
|
||||
|
||||
class Notification(object):
|
||||
def __init__(self, title="", msg="", icon=""):
|
||||
self.title = str(title)
|
||||
self.msg = str(msg)
|
||||
if icon.startswith("file://"):
|
||||
icon = icon[7:]
|
||||
self.icon = icon
|
||||
self.time = None
|
||||
|
||||
def set_duration(self, time):
|
||||
self.time = time
|
||||
|
||||
def show(self):
|
||||
try:
|
||||
if self.time is None:
|
||||
s.send("<root><title>" + self.title + "</title>"
|
||||
"<content>" + self.msg + "</content>"
|
||||
"<icon>" + self.icon + "</icon></root>")
|
||||
else:
|
||||
s.send("<root><title>" + self.title + "</title>"
|
||||
"<content>" + self.msg + "</content>"
|
||||
"<icon>" + self.icon + "</icon>"
|
||||
"<duration>" + str(self.time) + "</duration></root>")
|
||||
except:
|
||||
raise TwmnError(TwmnError.NO_TWMND)
|
||||
|
||||
if __name__ == "__main__":
|
||||
init()
|
||||
n = Notification("PyTwmn", "This is a notification!")
|
||||
n.set_duration(1000)
|
||||
n.show()
|
3
menus.py
3
menus.py
|
@ -1756,7 +1756,7 @@ class AboutPesterchum(QtWidgets.QDialog):
|
|||
self.mainwindow = parent
|
||||
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
|
||||
|
||||
self.title = QtWidgets.QLabel("P3ST3RCHUM V. %s" % (_pcVersion))
|
||||
self.title = QtWidgets.QLabel("P3ST3RCHUM %s" % (_pcVersion))
|
||||
self.credits = QtWidgets.QLabel("Programming by:\n\
|
||||
illuminatedwax (ghostDunk)\n\
|
||||
Kiooeht (evacipatedBox)\n\
|
||||
|
@ -1766,6 +1766,7 @@ class AboutPesterchum(QtWidgets.QDialog):
|
|||
Cerxi (binaryCabalist)\n\
|
||||
Arcane (arcaneAgilmente)\n\
|
||||
karxi (Midna)\n\
|
||||
Shou :)\n\
|
||||
\n\
|
||||
Art by:\n\
|
||||
Grimlive (aquaMarinist)\n\
|
||||
|
|
|
@ -74,6 +74,8 @@ if not ((major > 5) or (major == 5 and minor >= 0)):
|
|||
print("You currently have version " + vnum + ". Please upgrade Qt.")
|
||||
exit()
|
||||
|
||||
from version import _pcVersion
|
||||
|
||||
import ostools
|
||||
# Placed here before importing the rest of pesterchum, since bits of it need
|
||||
# OSX's data directory and it doesn't hurt to have everything set up before
|
||||
|
@ -127,7 +129,7 @@ import nickservmsgs
|
|||
# from updatecheck import MSPAChecker
|
||||
|
||||
from toast import PesterToastMachine, PesterToast
|
||||
from libs import pytwmn
|
||||
import pytwmn
|
||||
from profile import *
|
||||
|
||||
canon_handles = ["apocalypseArisen", "arsenicCatnip", "arachnidsGrip", "adiosToreador", \
|
||||
|
@ -2975,7 +2977,7 @@ class MainProgram(QtCore.QObject):
|
|||
# Back to our scheduled program.
|
||||
|
||||
self.app = QtWidgets.QApplication(sys.argv)
|
||||
self.app.setApplicationName("Pesterchum 3.14")
|
||||
self.app.setApplicationName("Pesterchum " + _pcVersion)
|
||||
self.app.setQuitOnLastWindowClosed(False)
|
||||
|
||||
options = self.oppts(sys.argv[1:])
|
||||
|
|
72
setup.py
72
setup.py
|
@ -1,11 +1,11 @@
|
|||
# Windows-only cx_freeze setup file
|
||||
from cx_Freeze import setup, Executable
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from version import buildVersion
|
||||
|
||||
if sys.version_info < (3, 0, 0):
|
||||
sys.exit("Python3 versions lower than 3 are not supported.")
|
||||
sys.exit("Python versions lower than 3 are not supported.")
|
||||
|
||||
def is_64bit() -> bool:
|
||||
return sys.maxsize > 2**32
|
||||
|
@ -13,47 +13,41 @@ def is_64bit() -> bool:
|
|||
if sys.platform == "win32":
|
||||
base = "Win32GUI"
|
||||
else:
|
||||
base = "Console"
|
||||
sys.exit("This script won't work on this platform </3")
|
||||
|
||||
includefiles = ["quirks",
|
||||
"smilies",
|
||||
"themes",
|
||||
"README.md",
|
||||
"README-karxi.mkdn",
|
||||
"README-pesterchum.mkdn",
|
||||
"themes.txt",
|
||||
"server.json",
|
||||
"PCskins.png",
|
||||
"Pesterchum.png"]
|
||||
build_exe_options = {
|
||||
"includes": ["requests","urllib"],
|
||||
'excludes': ['collections.sys',
|
||||
'collections._sre',
|
||||
'collections._json',
|
||||
'collections._locale',
|
||||
'collections._struct',
|
||||
'collections.array',
|
||||
'collections._weakref'],
|
||||
"includes": ["requests","urllib","pytwmn"],
|
||||
"excludes": ["collections.sys",
|
||||
"collections._sre",
|
||||
"collections._json",
|
||||
"collections._locale",
|
||||
"collections._struct",
|
||||
"collections.array",
|
||||
"collections._weakref"],
|
||||
'include_files': includefiles
|
||||
#'build_exe': ["build"]
|
||||
}
|
||||
if is_64bit() == true:
|
||||
#print("type(includefiles) = " + str(type(includefiles)))
|
||||
#print("type(build_exe_options) = " + str(type(build_exe_options))
|
||||
|
||||
if is_64bit() == True:
|
||||
setup(
|
||||
name = "PESTERCHUM",
|
||||
version = "3.41",
|
||||
description = "P3ST3RCHUM",
|
||||
name = "PESTERCHUM ALT.",
|
||||
version = buildVersion,
|
||||
url = "https://github.com/Dpeta/pesterchum-alt-servers",
|
||||
description = "P3ST3RCHUM ALT.",
|
||||
options = {"build_exe": build_exe_options},
|
||||
executables = [Executable("pesterchum.py",
|
||||
base=base,
|
||||
compress=True,
|
||||
icon="pesterchum.ico",
|
||||
build_exe: 'build\Pesterchum\'
|
||||
icon="pesterchum.ico"
|
||||
)])
|
||||
if sys.platform == "win32":
|
||||
os.rename("build/exe.win-amd64-2.7", "build/pesterchum")
|
||||
else:
|
||||
pass
|
||||
#Replace exe.win-amd64-2.7 with whatever it seems to generate as for you.
|
||||
|
||||
|
||||
shutil.copytree("themes", "build/pesterchum/themes")
|
||||
shutil.copytree("smilies", "build/pesterchum/smilies")
|
||||
shutil.copytree("quirks", "build/pesterchum/quirks")
|
||||
shutil.copy("pesterchum.nsi", "build/pesterchum/")
|
||||
shutil.copy("pesterchum-update.nsi", "build/pesterchum/")
|
||||
os.mkdir("build/pesterchum/profiles")
|
||||
os.mkdir("build/pesterchum/logs")
|
||||
|
||||
#Readme & txt
|
||||
shutil.copy("README.md", "build/pesterchum/")
|
||||
shutil.copy("README-pesterchum.mkdn", "build/pesterchum/")
|
||||
shutil.copy("README-karxi.mkdn", "build/pesterchum/")
|
||||
shutil.copy("themes.txt", "build/pesterchum/")
|
||||
|
|
2
toast.py
2
toast.py
|
@ -147,7 +147,7 @@ class ToastMachine(object):
|
|||
return
|
||||
#self.type = type = "default"
|
||||
elif type == "twmn":
|
||||
from libs import pytwmn
|
||||
import pytwmn
|
||||
try:
|
||||
pytwmn.init()
|
||||
except pytwmn.ERROR as e:
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
_pcVersion = "Alt. 2.0"
|
||||
buildVersion = "2.0"
|
||||
|
|
Loading…
Reference in a new issue