From 1aa4e65c7d4d2435a8bced1b3da7adbb11809fcc Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 11 Apr 2021 01:21:21 +0200 Subject: [PATCH] Logging, soundslider, and mood icon in trollian. --- CHANGELOG.md | 1 + console.py | 2 +- luaquirks.py | 2 +- memos.py | 2 +- parsetools.py | 11 ++++---- pesterchum.py | 70 +++++++++++++++++++++++++++++++-------------------- quirks.py | 8 +++--- randomer.py | 3 ++- toast.py | 6 ++--- 9 files changed, 62 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3514bfd..419319d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - Fixed "Report" string not being updated in convo window when changing theme. - Fixed pesterChumAction's text not being updated in memo windows when changing theme. - Fixed incorrect sRGB profile in paperchum. +- Fixed Sound slider in settings not working with pygame. ### Changed - Made it so handle and ident are passed to ``_max_msg_len``, so, hopefully the text cutoff will be *slightly* less restrictive. diff --git a/console.py b/console.py index b909d06..598fe3f 100644 --- a/console.py +++ b/console.py @@ -292,7 +292,7 @@ class ConsoleWindow(QtWidgets.QDialog): else: # No errors. if result is not None: - print(repr(result)) + logging.info(repr(result)) finally: # Restore system output. sys.stdout = sysout diff --git a/luaquirks.py b/luaquirks.py index a8f1205..daaaf70 100644 --- a/luaquirks.py +++ b/luaquirks.py @@ -18,7 +18,7 @@ class LuaQuirks(ScriptQuirks): try: return lua.require(name) except Error as e: - print(e) + logging.error(e) return None finally: os.chdir(CurrentDir) diff --git a/memos.py b/memos.py index 6e27c00..4776aff 100644 --- a/memos.py +++ b/memos.py @@ -894,7 +894,7 @@ class PesterMemo(PesterConvo): if c.lower() == self.channel.lower(): self.mainwindow.inviteOnlyChan['QString'].disconnect(self.closeInviteOnly) if self.parent(): - print(self.channel) + logging.info(self.channel) i = self.parent().tabIndices[self.channel] self.parent().tabClose(i) else: diff --git a/parsetools.py b/parsetools.py index c2083de..3e199f4 100644 --- a/parsetools.py +++ b/parsetools.py @@ -11,6 +11,7 @@ from quirks import ScriptQuirks from pyquirks import PythonQuirks from luaquirks import LuaQuirks import dataobjs +import logging # karxi: My own contribution to this - a proper lexer. import pnc.lexercon as lexercon @@ -42,7 +43,7 @@ quirkloader = ScriptQuirks() quirkloader.add(PythonQuirks()) quirkloader.add(LuaQuirks()) quirkloader.loadAll() -print(quirkloader.funcre()) +logging.info(quirkloader.funcre()) _functionre = re.compile(r"%s" % quirkloader.funcre()) _groupre = re.compile(r"\\([0-9]+)") @@ -398,7 +399,7 @@ def kxsplitMsg(lexed, ctx, fmt="pchum", maxlen=None, debug=False): while len(lexed) > 0: rounds += 1 if debug: - print("[Starting round {}...]".format(rounds)) + logging.info("[Starting round {}...]".format(rounds)) msg = lexed.popleft() msglen = 0 is_text = False @@ -439,7 +440,7 @@ def kxsplitMsg(lexed, ctx, fmt="pchum", maxlen=None, debug=False): # instead? subround += 1 if debug: - print("[Splitting round {}-{}...]".format( + logging.info("[Splitting round {}-{}...]".format( rounds, subround )) point = msg.rfind(' ', 0, lenl) @@ -454,12 +455,12 @@ def kxsplitMsg(lexed, ctx, fmt="pchum", maxlen=None, debug=False): # Remove what we just added. msg = msg[point:] if debug: - print("msg = {!r}".format(msg)) + logging.info("msg = {!r}".format(msg)) else: # Catch the remainder. stack.append(msg) if debug: - print("msg caught; stack = {!r}".format(stack)) + logging.info("msg caught; stack = {!r}".format(stack)) # Done processing. Pluck out the first portion so we can # continue processing, clean it up a bit, then add the rest to # our waiting list. diff --git a/pesterchum.py b/pesterchum.py index d97e172..9a23e99 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -9,7 +9,7 @@ except NameError: if os.path.dirname(sys.argv[0]): os.chdir(os.path.dirname(sys.argv[0])) import logging -logging.basicConfig(level=logging.WARNING) +logging.basicConfig(level=logging.DEBUG) from datetime import * import random @@ -48,19 +48,26 @@ except ImportError as e: if module.startswith("No module named ") or \ module.startswith("cannot import name "): reqmissing.append(module[module.rfind(" ")+1:]) - else: print(e) + else: logging.critical(e) del module + +# Because pygame intro msg :3c +# See https://stackoverflow.com/questions/54246668/how-do-i-delete-the-hello-from-the-pygame-community-console-alert-while-using +try: + os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1' +except: + logging.exception("Failed to set PYGAME_HIDE_SUPPORT_PROMPT, this is a non-issue.") try: import pygame except ImportError as e: pygame = None module = str(e) if module[:16] == "No module named ": optmissing.append(module[16:]) - else: print(e) + else: logging.critical(e) del module if reqmissing: - print("ERROR: The following modules are required for Pesterchum to run and are missing on your system:") - for m in reqmissing: print("* "+m) + logging.critical("ERROR: The following modules are required for Pesterchum to run and are missing on your system:") + for m in reqmissing: logging.critical("* "+m) # False flag for some reason. #exit() vnum = QtCore.qVersion() @@ -70,8 +77,8 @@ if vnum.find(".", vnum.find(".")+1) != -1: else: minor = int(vnum[vnum.find(".")+1:]) if not ((major > 5) or (major == 5 and minor >= 0)): - print("ERROR: Pesterchum requires at least Qt version >= 5.0") - print("You currently have version " + vnum + ". Please upgrade Qt.") + logging.critical("ERROR: Pesterchum requires at least Qt version >= 5.0") + logging.critical("You currently have version " + vnum + ". Please upgrade Qt.") exit() from version import _pcVersion @@ -329,7 +336,7 @@ class chumArea(RightClickTree): @QtCore.pyqtSlot() def beginNotify(self): - print("BEGIN NOTIFY") + logging.info("BEGIN NOTIFY") self.notify = True def getOptionsMenu(self): @@ -1341,8 +1348,8 @@ class PesterWindow(MovingWindow): self.lastping = int(time()) self.pingtimer.start(1000*90) - self.changeServerAskedToReset = False - self.changeServer() + self.chooseServerAskedToReset = False + self.chooseServer() @QtCore.pyqtSlot(QString, QString) def updateMsg(self, ver, url): @@ -1795,7 +1802,10 @@ class PesterWindow(MovingWindow): self.mychumcolor.setStyleSheet("background: %s" % (self.profile().colorhtml())) # I don't know why "if "main/mychumhandle/currentMood" in self.theme:" doesn't work, # But this seems to work just as well :3c - if self.theme.has_key("main/mychumhandle/currentMood"): + # GWAHH why does inheriting not work with this