Commit graph

81 commits

Author SHA1 Message Date
Lance Stout
4df3aa569b Bring back the signal handlers (and the "killed" event).
Now done more responsibly, saving any existing signal handlers
and calling them when an interrupt occurs in addition to the
one Sleek installs.

NOTE: You may need to explicitly use "kill <process id>" in
order to trigger the proper signal handler execution, and
to raise the "killed" event.
2011-02-23 10:20:04 -05:00
Lance Stout
d709f8db65 Use the _build_stanza method. 2011-02-14 13:50:59 -05:00
Lance Stout
75584d7ad7 Remap old method names in a better way.
This should prevent some reference cycles that will cause garbage
collection issues.
2011-02-14 13:49:43 -05:00
Lance Stout
8b5511c7ec Simplification when removing a deletable handler. 2011-02-13 16:40:04 -05:00
Lance Stout
38dc35840e Recognize stanzas that don't use the default namespace. 2011-01-27 15:59:50 -05:00
Lance Stout
cb85d4a529 Raise the event 'socket_error' when a socket error occurs.
Will be most useful for debugging and responding to failed
connection attempts.
2011-01-16 13:07:39 -05:00
Lance Stout
d7dea0c6cc Add a note for debug statement when running scheduled events.
Fixes the intermittent DEBUG ((),) messages that give no
explanation.

Will now show as:
DEBUG Scheduled event: ((), )
2011-01-14 12:07:25 -05:00
Lance Stout
34c374a1e1 Make tests pass for catching exceptions.
May now use sys.excepthook to catch exceptions
from threaded handlers.
2010-12-17 13:11:03 -05:00
Lance Stout
0aee445e69 Use daemon threads instead of signals.
Daemonized threads exit once the main program has quit,
and the only threads left running are all daemon threads.

Should fix hanging clients while not trampling over anyone
else's signal handlers.
2010-12-16 22:21:50 -05:00
Lance Stout
4b57b8131f Added support for using SSL CA certificates.
Originally provided by Brian Beggs (macdiesel)
and Thom Nichols (tomstrummer).
2010-12-16 17:30:08 -05:00
Lance Stout
f474d378ef Add support for using xml:lang values.
Support is only for adding literal XML content
to stanzas. Full support for things like multiple
message bodies with different xml:lang values is
still in the works.
2010-12-07 23:07:40 -05:00
Lance Stout
6ee8a2980c Fix RESPONSE_TIMEOUT dependency loops. 2010-11-17 15:13:09 -05:00
Lance Stout
4fb77ac878 Logging no longer uses root logger.
Each module should now log into its own logger.
2010-11-06 01:28:59 -04:00
Lance Stout
d0c506f930 Simplified SleekTest.
* check_stanza does not require stanza_class parameter. Introspection!
* check_message, check_iq, and check_presence removed -- use check
  instead.
* stream_send_stanza, stream_send_message, stream_send_iq, and
  stream_send_presence removed -- use send instead.
* Use recv instead of recv_message, recv_presence, etc.
* check_jid instead of check_JID
* stream_start may accept multi=True to return a new SleekTest instance
  for testing multiple streams at once.
2010-11-05 21:18:48 -04:00
Lance Stout
7351fe1a02 Fix bug introduced while fixing another bug.
Threaded event handlers now handle exceptions again.
2010-11-04 14:35:35 -04:00
Nathan Fritz
38c2f51f83 fixed indent errors 2010-11-04 11:39:41 -07:00
Lance Stout
5769935720 Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2010-11-03 12:39:44 -04:00
Lance Stout
0214db7545 Catch exceptions for direct events.
Events triggered with direct=True will have exceptions caught.

Note that all event handlers in a direct event will currently run
in the same thread.
2010-11-03 12:38:13 -04:00
Lance Stout
9e248bb852 Fix bug in XEP-0030 plugin.
xep_0030 still referenced event_handlers. Added the method event_handled
which will return the number of registered handlers for an event to
resolve the issue.
2010-10-31 18:27:52 -04:00
Lance Stout
973890e2c9 Added try/except for setting signal handlers.
Setting signal handlers from inside a thread is not supported in Python,
but some applications need to run Sleek from a child thread.

SleekXMPP applications that run inside a child thread will NOT be able
to detect SIGHUP or SIGTERM events. Those must be caught and managed by
the main program.
2010-10-28 10:42:23 -04:00
Lance Stout
9c08e56ed0 SSL and signal fixes.
Made setting the SIG* handlers conditional on if the signal defined for
the OS.

Added the attribute ssl_version to XMLStream to set the version of SSL
used during connection. It defaults to ssl.PROTOCOL_TLSv1, but OpenFire
tends to require ssl.PROTOCOL_SSLv23.
2010-10-27 19:27:47 -04:00
Lance Stout
5bdcd9ef9d Made exceptions work.
Raising an XMPPError exception from an event handler now works, even if
from a threaded handler.

Added stream tests to verify.

We should start using XMPPError, it really makes things simple!
2010-10-25 15:09:56 -04:00
Nathan Fritz
d88999691c misc small tweaks 2010-10-20 20:14:26 -07:00
Nathan Fritz
77eab6544f reconnect if session isn't established within 15 seconds 2010-10-20 19:18:27 -07:00
Nathan Fritz
11264fe0a8 capture SIGHUP and SIGTERM (windows) and disconnect; also testall no longer loads string26 with python3 2010-10-20 17:30:12 -07:00
Nathan Fritz
6e34b2cfdd fixed disconnect 2010-10-20 16:32:50 -07:00
Lance Stout
e18354ae0e Continue converting to underscored names. 2010-10-18 09:06:54 -04:00
Lance Stout
4375ac7d8b Underscore names by default.
Stanza objects now accept the use of underscored names.

The CamelCase versions are still available for backwards compatibility,
but are discouraged.

The property stanza.values now maps to the old getStanzaValues and
setStanzaValues, in addition to _set_stanza_values and
_get_stanza_values.
2010-10-17 22:04:42 -04:00
Lance Stout
505a63da3a Cleanup, restore PEP8. 2010-10-16 21:15:31 -04:00
Nathan Fritz
dc001bb201 deprecated jid, fulljid, server, user, resource properties and added boundjid JID 2010-10-14 15:50:54 -07:00
Nathan Fritz
0d0b963fe5 fixed socket name collision in xmlstream.py and fixed python 3.x compatibility 2010-10-14 10:58:07 -07:00
Nathan Fritz
a41a4369c6 disconnect cleanly 2010-10-13 18:21:05 -07:00
Nathan Fritz
7ad7a29a8f new state machine in place 2010-10-13 18:15:21 -07:00
Lance Stout
a8b948cd33 SleekTest may now run against a live stream.
Moved SleekTest to sleekxmpp.test package.
Corrected error in XML compare method.
Added TestLiveSocket to run stream tests against live streams.
Modified XMLStream to work with TestLiveSocket.
2010-10-07 19:43:51 -04:00
Lance Stout
78141fe5f3 Fixed dealing with deleting handlers.
The call to .index() may raise a ValueError if the item is not in the
list. So both the .index() and .pop() calls should be in the try block.
2010-10-07 09:17:28 -04:00
Lance Stout
d0ccbf6b7a Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop 2010-10-06 14:06:02 -04:00
Lance Stout
e1866ab328 Made first pass at cleaning up ClientXMPP.
Added self.stream_ns to BaseXMPP.
Moved connected/disconnected events and logging to XMLStream.
2010-10-06 14:03:19 -04:00
fritzy
3ffa09ba7c deal with deleting handlers that are no longer there 2010-10-06 17:58:03 +00:00
Lance Stout
178608f4c0 XMLStream cleanup.
Added RestartStream as a top level item in sleekxmpp.xmlstream.

Fixed trailing whitespace.
2010-10-06 10:45:36 -04:00
Lance Stout
9a34c9a9a1 Modified event handling to use the event queue.
Updated tests to match. (Needed to add a small wait to make sure
the event got through the queue before checking the results.)
2010-10-01 13:49:58 -04:00
Lance Stout
bb219595a7 Moved event functions to XMLStream.
This is just a transplant, modifying event to use the main
event queue has not been implemented yet.
2010-10-01 12:24:49 -04:00
Lance Stout
fcdd57ce54 Moved add_handler, send, and sendXML to XMLStream. 2010-10-01 11:15:51 -04:00
Lance Stout
5522443e0e Moved getNewId and getId to XMLStream.
This prepares the way for moving add_handler to XMLStream.

Since stanzas, matchers, and handlers in any XML stream will typically
use unique IDs, XMLStream is a good place for these methods.
2010-10-01 10:46:37 -04:00
Lance Stout
55cfe69fef Cleaned up trailing whitespace. 2010-10-01 10:09:10 -04:00
Lance Stout
6de87a1cbf Fixed line lengths and trailing whitespace.
The pep8 command is now pleased.
2010-09-30 13:06:16 -04:00
Lance Stout
7c10ff16fb Made a first pass at cleaning up XMLStream.
A few extra methods are mentioned in the docs, but those have not
been moved to XMLStream from BaseXMPP yet.
2010-09-30 12:56:22 -04:00
Lance Stout
89fb15e896 Updated the suite of handler classes with documentation.
Updated XMLStream to return True or False from removeHandler to indicate if the handler
existed and was removed.

Waiter handlers now unregister themselves after timing out.
2010-08-27 16:42:26 -04:00
Lance Stout
6677df39f2 Updated xmlstream.filesocket. 2010-08-27 11:29:48 -04:00
Lance Stout
4d1f071f83 Updated the use of tostring in xmlstream.py
Now uses the xmlns and stream parameters to reduce the number of
extra xmlns attributes used in the logging output.

Added self.default_ns to XMLStream just to be safe.
2010-08-05 23:11:22 -04:00
Lance Stout
e077204a16 Replaced the ToString class with a tostring function.
The sleekxmpp.xmlstream.tostring and sleekxmpp.xmlstream.tostring26 packages
have been merged to sleekxmpp.xmlstream.tostring. The __init__.py file will
import the appropriate tostring function depending on the Python version.

The setup.py file has been updated with the package changes.

ElementBase is now a direct descendent of object and does not subclass ToString.

Stanza objects now return their XML contents for __repr__.
2010-08-05 20:26:41 -04:00