Fix Pylint errors and further disable console, as it is unmaintained.

Remove osVer function from ostools

Remove isOSXLeopard

only use chum.handle

Fix bad except error

Comment out console related function

fix fix* except order

fallback if i is not defined for log

fix console

Explicitly define nick() to appease pylint

Comment out connect_cb, it's unused for pchum rn

e is unsubscribable

Explicitly define 'simple' irc commands

fix exceptions part 2

fix send

Explicitly define lastmsg as None on init

iterate through copy or urls

Comment out console for not as it's unmaintained
This commit is contained in:
Dpeta 2023-01-14 21:52:07 +01:00
parent 4dfebfaba1
commit bc4af153af
No known key found for this signature in database
GPG key ID: 51227517CEA0030C
8 changed files with 41 additions and 67 deletions

View file

@ -1,3 +1,4 @@
"""
# vim: set autoindent ts=4 sts=4 sw=4 textwidth=79 expandtab:
# -*- coding=UTF-8; tab-width: 4 -*-
# import os
@ -550,3 +551,4 @@ class ConsoleInput(QtWidgets.QLineEdit):
parent.text.area.keyPressEvent(event)
else:
super(ConsoleInput, self).keyPressEvent(event)
"""

View file

@ -390,6 +390,7 @@ class PesterText(QtWidgets.QTextEdit):
self.textSelected = False
self.copyAvailable[bool].connect(self.textReady)
self.urls = {}
self.lastmsg = None
for k in smiledict:
self.addAnimation(
QtCore.QUrl("smilies/%s" % (smiledict[k])),
@ -549,9 +550,13 @@ class PesterText(QtWidgets.QTextEdit):
and not parent.isBot(chum.handle)
):
idlethreshhold = 60
if (
not hasattr(self, "lastmsg")
) or datetime.now() - self.lastmsg > timedelta(0, idlethreshhold):
do_idle_send = False
if self.lastmsg is None:
do_idle_send = True
else:
if datetime.now() - self.lastmsg > timedelta(0, idlethreshhold):
do_idle_send = True
if do_idle_send:
verb = window.theme["convo/text/idle"]
idlemsg = me.idlemsg(systemColor, verb)
parent.textArea.append(convertTags(idlemsg))
@ -995,7 +1000,7 @@ class PesterConvo(QtWidgets.QFrame):
def closeEvent(self, event):
self.mainwindow.waitingMessages.messageAnswered(self.title())
for movie in self.textArea.urls:
for movie in self.textArea.urls.copy():
movie.setFileName("") # Required, sometimes, for some reason. . .
movie.stop()
del movie

View file

@ -398,12 +398,7 @@ class MemoText(PesterText):
# new chum! time current
newtime = timedelta(0)
time = TimeTracker(newtime)
# 'handle' undefined?
try:
parent.times[handle] = time
except:
parent.times[chum.handle] = time
parent.times[chum.handle] = time
else:
time = parent.time

View file

@ -1,7 +1,6 @@
import os
import sys
import ctypes
import platform
try:
from PyQt6.QtCore import QStandardPaths
@ -26,20 +25,6 @@ def isOSXBundle():
return isOSX() and (os.path.abspath(".").find(".app") != -1)
def isOSXLeopard():
return isOSX() and platform.mac_ver()[0].startswith("10.5")
def osVer():
if isWin32():
return " ".join(platform.win32_ver())
elif isOSX():
ver = platform.mac_ver()
return " ".join((ver[0], " (", ver[2], ")"))
elif isLinux():
return " ".join(platform.linux_distribution())
def isRoot():
"""Return True if running with elevated privileges."""
# Windows

View file

@ -100,7 +100,7 @@ class IRCClient:
self.username = None
self.host = None
self.port = None
self.connect_cb = None
#self.connect_cb = None
self.timeout = None
self.blocking = None
self.ssl = None
@ -273,8 +273,8 @@ class IRCClient:
helpers.nick(self, self.nick)
helpers.user(self, self.username, self.realname)
if self.connect_cb:
self.connect_cb(self)
#if self.connect_cb:
# self.connect_cb(self)
def conn(self):
"""returns a generator object."""
@ -337,11 +337,7 @@ class IRCClient:
PchumLog.warning("conn exception %s in %s" % (e, self))
if self._end:
break
try: # a little dance of compatibility to get the errno
errno = e.errno
except AttributeError:
errno = e[0]
if not self.blocking and errno == 11:
if not self.blocking and e.errno == 11:
pass
else:
raise e

View file

@ -115,35 +115,24 @@ def identify(cli, passwd, authuser="NickServ"):
def quit(cli, msg):
cli.send("QUIT %s" % (msg))
def nick(cli, nick):
cli.send(f"NICK", nick)
def user(cli, username, realname):
cli.send("USER", username, "0", "*", ":" + realname)
def join(cli, channel):
"""Protocol potentially allows multiple channels or keys."""
cli.send("JOIN", channel)
_simple = (
"join",
"part",
"nick",
"notice",
"invite",
)
def part(cli, channel):
cli.send("PART", channel)
def notice(cli, target, text):
cli.send("NOTICE", target, text)
def _addsimple():
import sys
def simplecmd(cmd_name):
def f(cli, *args):
cli.send(cmd_name, *args)
return f
m = sys.modules[__name__]
for t in _simple:
setattr(m, t, simplecmd(t.upper()))
_addsimple()
def invite(cli, nick, channel):
cli.send("INVITE", nick, channel)
def _addNumerics():

View file

@ -1461,6 +1461,7 @@ class PesterWindow(MovingWindow):
self.menu.setNativeMenuBar(False)
self.menu.setObjectName("mainmenu")
"""
if self.theme.has_key("main/menus/client/console"):
self.console = AttrDict(
dict(
@ -1498,6 +1499,7 @@ class PesterWindow(MovingWindow):
# ~self.connect(self.console.shortcuts.curwgt,
# ~ QtCore.SIGNAL('activate()'), self.console.
self.console.is_open = False
"""
filemenu = self.menu.addMenu(self.theme["main/menus/client/_name"])
self.filemenu = filemenu
@ -2003,6 +2005,7 @@ class PesterWindow(MovingWindow):
self.tabmemo = MemoTabWindow(self)
self.tabmemo.windowClosed.connect(self.memoTabsClosed)
"""
@QtCore.pyqtSlot()
def toggleConsole(self):
if not _CONSOLE:
@ -2070,6 +2073,7 @@ class PesterWindow(MovingWindow):
self.console.is_open = False
self.console.window = None
PchumLog.info("Console closed.")
"""
def newMemo(self, channel, timestr, secret=False, invite=False):
if channel == "#pesterchum":
@ -2215,10 +2219,10 @@ class PesterWindow(MovingWindow):
## else:
## self.console.action.setText("Console")
# has_key doesn't work out here for some reason, possibly because of inherits?
try:
self.console.action.setText(self.theme["main/menus/client/console"])
except:
self.console.action.setText("Console")
#try:
# self.console.action.setText(self.theme["main/menus/client/console"])
#except:
# self.console.action.setText("Console")
try:
self.reportBugAction.setText(self.theme["main/menus/help/reportbug"])

View file

@ -225,15 +225,12 @@ with a backup from: <a href='%s'>%s</a></h3></html>"
pzip.writestr(x, f.read())
PchumLog.info("Updated backups-%s." % current_backup)
except OSError as e:
PchumLog.warning("Failed to make backup, no permission?")
PchumLog.warning(e)
except shutil.Error as e:
PchumLog.warning("Failed to make backup, shutil error?")
PchumLog.warning(e)
PchumLog.warning(f"Failed to make backup, shutil error?\n{e}")
except zipfile.BadZipFile as e:
PchumLog.warning("Failed to make backup, BadZipFile?")
PchumLog.warning(e)
PchumLog.warning(f"Failed to make backup, BadZipFile?\n{e}")
except OSError as e:
PchumLog.warning(f"Failed to make backup, no permission?\n{e}")
def chums(self):
if "chums" not in self.config:
@ -736,6 +733,7 @@ class userProfile(object):
return self.mentions
def setMentions(self, mentions):
i = None
try:
for (i, m) in enumerate(mentions):
re.compile(m)