From 90be0894fbe6a485f54b0361deaabded74bb8301 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 24 Mar 2021 22:34:55 +0100 Subject: [PATCH] Preparation for building :) --- libs/pytwmn.py | 76 -------------------------------------------------- menus.py | 3 +- pesterchum.py | 6 ++-- setup.py | 72 ++++++++++++++++++++++------------------------- toast.py | 2 +- version.py | 1 + 6 files changed, 41 insertions(+), 119 deletions(-) delete mode 100644 libs/pytwmn.py diff --git a/libs/pytwmn.py b/libs/pytwmn.py deleted file mode 100644 index 6b2d774..0000000 --- a/libs/pytwmn.py +++ /dev/null @@ -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("" + self.title + "" - "" + self.msg + "" - "" + self.icon + "") - else: - s.send("" + self.title + "" - "" + self.msg + "" - "" + self.icon + "" - "" + str(self.time) + "") - except: - raise TwmnError(TwmnError.NO_TWMND) - -if __name__ == "__main__": - init() - n = Notification("PyTwmn", "This is a notification!") - n.set_duration(1000) - n.show() diff --git a/menus.py b/menus.py index 00c803a..b01bb5a 100644 --- a/menus.py +++ b/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\ diff --git a/pesterchum.py b/pesterchum.py index b27ea2f..9d54e97 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -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:]) diff --git a/setup.py b/setup.py index cae815e..8092a11 100644 --- a/setup.py +++ b/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