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

View file

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

View file

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

View file

@ -1,7 +1,6 @@
import os import os
import sys import sys
import ctypes import ctypes
import platform
try: try:
from PyQt6.QtCore import QStandardPaths from PyQt6.QtCore import QStandardPaths
@ -26,20 +25,6 @@ def isOSXBundle():
return isOSX() and (os.path.abspath(".").find(".app") != -1) 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(): def isRoot():
"""Return True if running with elevated privileges.""" """Return True if running with elevated privileges."""
# Windows # Windows

View file

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

View file

@ -115,35 +115,24 @@ def identify(cli, passwd, authuser="NickServ"):
def quit(cli, msg): def quit(cli, msg):
cli.send("QUIT %s" % (msg)) cli.send("QUIT %s" % (msg))
def nick(cli, nick):
cli.send(f"NICK", nick)
def user(cli, username, realname): def user(cli, username, realname):
cli.send("USER", username, "0", "*", ":" + realname) cli.send("USER", username, "0", "*", ":" + realname)
def join(cli, channel):
"""Protocol potentially allows multiple channels or keys."""
cli.send("JOIN", channel)
_simple = ( def part(cli, channel):
"join", cli.send("PART", channel)
"part",
"nick",
"notice",
"invite",
)
def notice(cli, target, text):
cli.send("NOTICE", target, text)
def _addsimple(): def invite(cli, nick, channel):
import sys cli.send("INVITE", nick, channel)
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 _addNumerics(): def _addNumerics():

View file

@ -1461,6 +1461,7 @@ class PesterWindow(MovingWindow):
self.menu.setNativeMenuBar(False) self.menu.setNativeMenuBar(False)
self.menu.setObjectName("mainmenu") self.menu.setObjectName("mainmenu")
"""
if self.theme.has_key("main/menus/client/console"): if self.theme.has_key("main/menus/client/console"):
self.console = AttrDict( self.console = AttrDict(
dict( dict(
@ -1498,7 +1499,8 @@ class PesterWindow(MovingWindow):
# ~self.connect(self.console.shortcuts.curwgt, # ~self.connect(self.console.shortcuts.curwgt,
# ~ QtCore.SIGNAL('activate()'), self.console. # ~ QtCore.SIGNAL('activate()'), self.console.
self.console.is_open = False self.console.is_open = False
"""
filemenu = self.menu.addMenu(self.theme["main/menus/client/_name"]) filemenu = self.menu.addMenu(self.theme["main/menus/client/_name"])
self.filemenu = filemenu self.filemenu = filemenu
filemenu.addAction(opts) filemenu.addAction(opts)
@ -2003,6 +2005,7 @@ class PesterWindow(MovingWindow):
self.tabmemo = MemoTabWindow(self) self.tabmemo = MemoTabWindow(self)
self.tabmemo.windowClosed.connect(self.memoTabsClosed) self.tabmemo.windowClosed.connect(self.memoTabsClosed)
"""
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def toggleConsole(self): def toggleConsole(self):
if not _CONSOLE: if not _CONSOLE:
@ -2070,6 +2073,7 @@ class PesterWindow(MovingWindow):
self.console.is_open = False self.console.is_open = False
self.console.window = None self.console.window = None
PchumLog.info("Console closed.") PchumLog.info("Console closed.")
"""
def newMemo(self, channel, timestr, secret=False, invite=False): def newMemo(self, channel, timestr, secret=False, invite=False):
if channel == "#pesterchum": if channel == "#pesterchum":
@ -2215,10 +2219,10 @@ class PesterWindow(MovingWindow):
## else: ## else:
## self.console.action.setText("Console") ## self.console.action.setText("Console")
# has_key doesn't work out here for some reason, possibly because of inherits? # has_key doesn't work out here for some reason, possibly because of inherits?
try: #try:
self.console.action.setText(self.theme["main/menus/client/console"]) # self.console.action.setText(self.theme["main/menus/client/console"])
except: #except:
self.console.action.setText("Console") # self.console.action.setText("Console")
try: try:
self.reportBugAction.setText(self.theme["main/menus/help/reportbug"]) 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()) pzip.writestr(x, f.read())
PchumLog.info("Updated backups-%s." % current_backup) 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: except shutil.Error as e:
PchumLog.warning("Failed to make backup, shutil error?") PchumLog.warning(f"Failed to make backup, shutil error?\n{e}")
PchumLog.warning(e)
except zipfile.BadZipFile as e: except zipfile.BadZipFile as e:
PchumLog.warning("Failed to make backup, BadZipFile?") PchumLog.warning(f"Failed to make backup, BadZipFile?\n{e}")
PchumLog.warning(e) except OSError as e:
PchumLog.warning(f"Failed to make backup, no permission?\n{e}")
def chums(self): def chums(self):
if "chums" not in self.config: if "chums" not in self.config:
@ -736,6 +733,7 @@ class userProfile(object):
return self.mentions return self.mentions
def setMentions(self, mentions): def setMentions(self, mentions):
i = None
try: try:
for (i, m) in enumerate(mentions): for (i, m) in enumerate(mentions):
re.compile(m) re.compile(m)