473,385 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

irclib problems

I'm playing around with the 'irclib' library working with the first
example at
http://www.devshed.com/c/a/Python/IR...vel-Concluded/

When copying the example verbatim and running it from a console it works
flawlessly. It connects to the server, join the channel and sits there
'forever'...

However, I want to use it in a PyQt application and have done the following.
I have created a module named 'irclibtest.py' that looks like this:

### irclibtest start ###
import irclib
irclib.DEBUG = True

class Conn:
def __init__(self):
# Network information
self.network = '192.x.x.x'
self.port = 6667
self.channel = '#test'
self.nick = 'IRClibt'
self.name = 'Python Test'

# Subclass SimpleIRCClient
class ClientClass ( irclib.SimpleIRCClient ):
pass

# Create an instance of ClientClass and connect.
self.client = ClientClass()
self.client.connect ( self.network, self.port, self.nick,
ircname = self.name )
self.client.connection.join ( self.channel )
##irclibtest end ###

And my main Qt application:

### Main application start ###
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, irclib
from PyQt4 import QtGui , QtCore
from tircUI import Ui_MainWindow
from irclibtest import Conn

class TircMain(QtGui.QMainWindow , Conn):
def __init__(self):
QtGui.QMainWindow.__init__(self )
Conn.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)

self.connect(self.ui.sendButton, QtCore.SIGNAL("clicked()"),
self.doSend)

def doSend(self):
''' Just a test to see if I can send to channel'''
self.client.connection.privmsg('#test' , 'Test text')

if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
f = TircMain()
f.show()
sys.exit(app.exec_())
### Main application end ##

The problem is that this pings out (PING timeout). As far as I
understand it rclib.SimpleIRCClient is supposed to handle PING-PONG with
the server so I don't understand why it does not in my Qt test, but it
does 'raw'.
I can send to the channel right up to the point it times out by the way.

Anyone know what I'm missing here?

Thanks
Tina
Feb 11 '07 #1
1 1979
On Sunday 11 February 2007 09:29, Tina I wrote:
I'm playing around with the 'irclib' library working with the first
example at
http://www.devshed.com/c/a/Python/IR...vel-Concluded/

When copying the example verbatim and running it from a console it works
flawlessly. It connects to the server, join the channel and sits there
'forever'...
OK. So it works on its own.
However, I want to use it in a PyQt application and have done the
following. I have created a module named 'irclibtest.py' that looks like
this:
[...]

class Conn:
*****def*__init__(self):
*********#*Network*information
*********self.network*=*'192.x.x.x'
*********self.port*=*6667
*********self.channel*=*'#test'
*********self.nick*=*'IRClibt'
*********self.name*=*'Python*Test'

*********#*Subclass*SimpleIRCClient
*********class*ClientClass*(*irclib.SimpleIRCClien t*):
*************pass

*********#*Create*an*instance*of*ClientClass*and*c onnect.
*********self.client*=*ClientClass()
*********self.client.connect*(*self.network,*self. port,*self.nick,
ircname = self.name )
*********self.client.connection.join*(*self.channe l*)

[...]
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
f = TircMain()
f.show()
sys.exit(app.exec_())
### Main application end ##

The problem is that this pings out (PING timeout). As far as I
understand it rclib.SimpleIRCClient is supposed to handle PING-PONG with
the server so I don't understand why it does not in my Qt test, but it
does 'raw'.
You don't call self.client.start() anywhere. Even if you did, you
would still have problems because you need to call app.exec_(), and
this would only happen after self.client.start() returns - if ever.
I can send to the channel right up to the point it times out by the way.
I think this is just a result of the way the IRC protocol works.
Anyone know what I'm missing here?
You have an application with two event loops, and you can't run them
both in the usual way. If SimpleIRCClient has a method that only
processes pending events and returns immediately afterwards, you could
create a QTimer, connect its timeout() signal to that method, and make
it fire every half a second or so, to ensure that the client doesn't
time out.

There may be other solutions with threads, but things could get
quite complicated. Making one event loop play well with the other
is probably the best approach to take.

David
Feb 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jerome Lefebvre | last post by:
Hello, Hope this will interest a few. I been working with a friend on the problems given out during the "International Collegiate Programming Contest" (ICPC) http://icpc.baylor.edu/icpc/ ....
14
by: Jim Hubbard | last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework? Not if you are unaware of the 1,596 issues listed at KBAlertz (http://www.kbalertz.com/technology_3.aspx). If you are...
1
by: 3f | last post by:
Hello; We have made a web application that people can download from our web site and installed on: Windows XP Windows 2000 Professional Windows 2003 Server Windows 2000 Server
5
by: Corky | last post by:
This works: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID = PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
0
by: Sergistm | last post by:
Hello World, :D I have a problem that it is making me crazy, I hope you can help me. I'm trying to execute a .exe file with the Procces.Start, and there is no problem when the file is on my...
0
by: shonen | last post by:
Hi guys! Alright so here is my question, I've been messing around with irclib in my python programs creating a bot. I just want to add a little bit of functionality to it! So basically, what...
3
by: Dropkick Punt | last post by:
Hi. I've written a bot in python, using the irclib by Joel Rosdahl. Works fine from my linux box at home, but when I upload it to my shell at veritynet.net, can't seem to get it to connect to an...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.