Access parent, fixes for last few commits
This commit is contained in:
parent
c13c05f51d
commit
cb1e2e051e
4 changed files with 30 additions and 23 deletions
|
@ -154,16 +154,16 @@ class IRCClient:
|
|||
while retry < 5:
|
||||
try:
|
||||
ready_to_read, ready_to_write, in_error = select.select([], [self.socket], [])
|
||||
PchumLog.debug("ready_to_write (len %s): " % len(ready_to_write) + str(ready_to_write))
|
||||
PchumLog.debug("ready_to_write (len %s): " % str(len(ready_to_write)) + str(ready_to_write))
|
||||
#ready_to_write[0].sendall(msg + bytes("\r\n", "UTF-8"))
|
||||
for x in ready_to_write:
|
||||
x.sendall(msg + bytes("\r\n", "UTF-8"))
|
||||
break
|
||||
except socket.error as e:
|
||||
retry += 1
|
||||
PchumLog.warning("socket.error (retry %s) %s" % (retry, e))
|
||||
PchumLog.warning("socket.error (retry %s) %s" % (str(retry), str(e)))
|
||||
except socket.error as se:
|
||||
PchumLog.warning("socket.error %s" % se)
|
||||
PchumLog.warning("socket.error %s" % str(se))
|
||||
try: # a little dance of compatibility to get the errno
|
||||
errno = se.errno
|
||||
except AttributeError:
|
||||
|
@ -206,7 +206,7 @@ class IRCClient:
|
|||
#print(buffer)
|
||||
#raise socket.timeout
|
||||
except socket.timeout as e:
|
||||
PchumLog.warning("timeout in client.py, " + e)
|
||||
PchumLog.warning("timeout in client.py, " + str(e))
|
||||
if self._end:
|
||||
break
|
||||
raise e
|
||||
|
@ -241,20 +241,20 @@ class IRCClient:
|
|||
try:
|
||||
self.command_handler.run(command, prefix, *args)
|
||||
except CommandError as e:
|
||||
PchumLog.debug("CommandError %s" % e)
|
||||
PchumLog.debug("CommandError %s" % str(e))
|
||||
|
||||
yield True
|
||||
except socket.timeout as se:
|
||||
PchumLog.debug("passing timeout")
|
||||
raise se
|
||||
except socket.error as se:
|
||||
PchumLog.debug("problem: %s" % (se))
|
||||
PchumLog.debug("problem: %s" % (str(se)))
|
||||
if self.socket:
|
||||
PchumLog.info('error: closing socket')
|
||||
self.socket.close()
|
||||
raise se
|
||||
except Exception as e:
|
||||
PchumLog.debug("other exception: %s" % e)
|
||||
PchumLog.debug("other exception: %s" % str(e))
|
||||
raise e
|
||||
else:
|
||||
PchumLog.debug("ending while, end is %s" % self._end)
|
||||
|
@ -269,13 +269,13 @@ class IRCClient:
|
|||
#print("shutdown socket")
|
||||
self._end = True
|
||||
try:
|
||||
self.socket.shutdown(SHUT_RDWR)
|
||||
self.socket.shutdown(socket.SHUT_RDWR)
|
||||
except OSError as e:
|
||||
PchumLog.warning("Error while shutting down socket, already broken? %s" % e)
|
||||
PchumLog.warning("Error while shutting down socket, already broken? %s" % str(e))
|
||||
try:
|
||||
self.socket.close()
|
||||
except OSError as e:
|
||||
PchumLog.warning("Error while closing socket, already broken? %s" % e)
|
||||
PchumLog.warning("Error while closing socket, already broken? %s" % str(e))
|
||||
|
||||
def quit(self, msg):
|
||||
PchumLog.info("QUIT")
|
||||
|
@ -332,7 +332,7 @@ class IRCApp:
|
|||
try:
|
||||
next(clientdesc.con)
|
||||
except Exception as e:
|
||||
PchumLog.error('client error %s' % e)
|
||||
PchumLog.error('client error %s' % str(e))
|
||||
PchumLog.error(traceback.format_exc())
|
||||
if clientdesc.autoreconnect:
|
||||
clientdesc.con = None
|
||||
|
|
|
@ -107,7 +107,7 @@ class CommandHandler(object):
|
|||
try:
|
||||
f(*args)
|
||||
except TypeError as e:
|
||||
logging.exception("Failed to pass command, did the server pass an unsupported paramater?\n%s" % e)
|
||||
logging.exception("Failed to pass command, did the server pass an unsupported paramater?\n%s" % str(e))
|
||||
|
||||
@protected
|
||||
def __unhandled__(self, cmd, *args):
|
||||
|
|
|
@ -48,7 +48,7 @@ def parse_raw_irc_command(element):
|
|||
try:
|
||||
element = element.decode("utf-8")
|
||||
except UnicodeDecodeError as e:
|
||||
PchumLog.debug("utf-8 error %s" % e)
|
||||
PchumLog.debug("utf-8 error %s" % str(e))
|
||||
element = element.decode("latin-1", 'replace')
|
||||
|
||||
parts = element.strip().split(" ")
|
||||
|
|
|
@ -1146,7 +1146,7 @@ class PesterWindow(MovingWindow):
|
|||
sendMessage = QtCore.pyqtSignal('QString', 'QString')
|
||||
|
||||
def __init__(self, options, parent=None, app=None):
|
||||
super(PesterWindow, self).__init__(parent,
|
||||
super(PesterWindow, self).__init__(None,
|
||||
(QtCore.Qt.CustomizeWindowHint |
|
||||
QtCore.Qt.FramelessWindowHint))
|
||||
|
||||
|
@ -1165,6 +1165,7 @@ class PesterWindow(MovingWindow):
|
|||
|
||||
self.autoJoinDone = False
|
||||
self.app = app
|
||||
self.parent = parent
|
||||
self.convos = CaseInsensitiveDict()
|
||||
self.memos = CaseInsensitiveDict()
|
||||
self.tabconvo = None
|
||||
|
@ -3159,12 +3160,13 @@ class PesterWindow(MovingWindow):
|
|||
@QtCore.pyqtSlot()
|
||||
def quit(self):
|
||||
try:
|
||||
pesterchum.irc.quit_dc() # Actually send QUIT to server
|
||||
except:
|
||||
self.irc.quit_dc() # Actually send QUIT to server
|
||||
except Exception as e:
|
||||
# Not connected.
|
||||
pass
|
||||
pesterchum.trayicon.hide() #
|
||||
pesterchum.app.quit() #
|
||||
PchumLog.warning("QUIT failed: " + str(e))
|
||||
|
||||
self.parent.trayicon.hide() #
|
||||
self.app.quit() #
|
||||
|
||||
def passIRC(self, irc):
|
||||
self.irc = irc
|
||||
|
@ -3407,9 +3409,10 @@ class PesterWindow(MovingWindow):
|
|||
PchumLog.error("Failed to set server :(")
|
||||
|
||||
# Continue running Pesterchum as usual
|
||||
pesterchum.irc.start()
|
||||
pesterchum.reconnectok = False
|
||||
pesterchum.showLoading(pesterchum.widget)
|
||||
# Sorry-
|
||||
self.irc.start()
|
||||
self.parent.reconnectok = False
|
||||
self.parent.showLoading(self.parent.widget)
|
||||
self.show() # Not required?
|
||||
self.setFocus()
|
||||
|
||||
|
@ -3582,7 +3585,7 @@ class MainProgram(QtCore.QObject):
|
|||
# print("Warning: No sound! (No pygame/QSound)")
|
||||
|
||||
doSoundInit()
|
||||
self.widget = PesterWindow(options, app=self.app)
|
||||
self.widget = PesterWindow(options, parent=self, app=self.app)
|
||||
#self.widget.show() <== Already called in showLoading()
|
||||
|
||||
self.trayicon = PesterTray(PesterIcon(self.widget.theme["main/icon"]), self.widget, self.app)
|
||||
|
@ -3883,6 +3886,10 @@ def _retrieveGlobals():
|
|||
# properly. I'm open to alternatives.
|
||||
return globals()
|
||||
|
||||
#def main():
|
||||
# pesterchum = MainProgram()
|
||||
# pesterchum.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# We're being run as a script - not being imported.
|
||||
pesterchum = MainProgram()
|
||||
|
|
Loading…
Reference in a new issue