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