diff options
| author | Miklos Vajna <vmiklos@frugalware.org> | 2010-12-13 04:37:30 +0100 | 
|---|---|---|
| committer | Miklos Vajna <vmiklos@frugalware.org> | 2010-12-13 04:37:30 +0100 | 
| commit | a618ea653d159324a9691af06d3da42373f27be9 (patch) | |
| tree | 9e7272a7297a79803ede1eb8a93110711a8d593b /skype/skyped.py | |
| parent | 451f1210e64b9e2a8e606dc3103d73d15b89ca8e (diff) | |
new testcase
Diffstat (limited to 'skype/skyped.py')
| -rw-r--r-- | skype/skyped.py | 23 | 
1 files changed, 21 insertions, 2 deletions
| diff --git a/skype/skyped.py b/skype/skyped.py index 8ce35777..f15245ed 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -37,9 +37,12 @@ import ssl  __version__ = "0.1.1"  def eh(type, value, tb): +	global options +  	if type != KeyboardInterrupt:  		print_exception(type, value, tb)  	gobject.MainLoop().quit() +	options.conn.close()  	# shut down client if it's running  	try:  		skype.skype.Client.Shutdown() @@ -74,11 +77,26 @@ def skype_idle_handler(skype):  		dprint("Warning, pinging Skype failed (%s)." % (s))  	return True +def send(sock, txt): +	from time import sleep +	count = 1 +	done = False +	while (not done) and (count < 10): +		try: +			sock.send(txt) +			done = True +		except Exception, s: +			count += 1 +			dprint("Warning, sending '%s' failed (%s). count=%d" % (txt, s, count)) +			sleep(1) +	if not done: +		options.conn.close() +  def bitlbee_idle_handler(skype):  	if options.conn:  		try:  			e = "PING" -			options.conn.send("%s\n" % e) +			send(options.conn, "%s\n" % e)  		except Exception, s:  			dprint("Warning, sending '%s' failed (%s)." % (e, s))  			options.conn.close() @@ -136,6 +154,7 @@ def dprint(msg):  	if options.debug:  		print now + ": " + msg +		sys.stdout.flush()  	if options.log:  		sock = open(options.log, "a")  		sock.write("%s: %s\n" % (now, msg)) @@ -171,7 +190,7 @@ class SkypeApi:  			dprint('<< ' + e)  			if options.conn:  				try: -					options.conn.send(e + "\n") +					send(options.conn, e + "\n")  				except Exception, s:  					dprint("Warning, sending '%s' failed (%s)." % (e, s))  					options.conn.close() | 
