def plugin_init(self): self.description = "Kestrel Dispatcher" self.backend = self.config.get('backend', None) self.xmpp.registerHandler( Callback('Kestrel Task', MatchXPath('{%s}iq/{%s}task' % (self.xmpp.default_ns, Task.namespace)), self.handle_task)) registerStanzaPlugin(Iq, Task) self.xmpp.add_event_handler('kestrel_task_cancelled', self.cancel_task) self.xmpp.add_event_handler('kestrel_job_queued', self.dispatch_job) self.xmpp.add_event_handler('kestrel_worker_available', self.dispatch_worker) self.xmpp.add_event_handler('kestrel_worker_offline', self.reset_worker_tasks)
def plugin_init(self): self.description = "Kestrel Worker" self.capabilities = self.config.get('capabilities', []) self.xmpp.registerHandler( Callback('Kestrel Task', MatchXPath('{%s}iq/{%s}task' % (self.xmpp.default_ns, Task.namespace)), self.handle_task)) registerStanzaPlugin(Iq, Task) self.xmpp.add_event_handler('kestrel_task', self.start_task, threaded=True) self.xmpp.add_event_handler('kestrel_task_cancel', self.cancel_task, threaded=True) self.tasks = {} self.max_tasks = 1 self.lock = threading.Lock()
def plugin_init(self): self.description = "Kestrel Worker Pool" self.backend = self.config.get('backend', None) self.pool_jid =self.config.get('jid', self.xmpp.fulljid) self.xmpp.registerHandler( Callback('Kestrel Pool Status', MatchXPath('{%s}iq/{%s}query' % (self.xmpp.default_ns, Status.namespace)), self.handle_status)) registerStanzaPlugin(Iq, Status) registerStanzaPlugin(Status, PoolStatus) self.xmpp.add_event_handler('got_online', self.online, threaded=True) self.xmpp.add_event_handler('changed_status', self.changed) self.xmpp.add_event_handler('got_offline', self.offline) self.xmpp.add_event_handler('disco_info', self.check_info) self.backend.workers.clean()
def plugin_init(self): self.description = "Kestrel Client" self.manager = self.config.get('manager', '') self.submit_jid = 'submit@%s' % self.manager self.xmpp.registerHandler( Callback('Kestrel Job', MatchXPath('{%s}iq/{%s}job' % (self.xmpp.default_ns, Job.namespace)), self.handle_job)) registerStanzaPlugin(Iq, Job) self.xmpp.registerHandler( Callback('Kestrel Status', MatchXPath('{%s}iq/{%s}query' % (self.xmpp.default_ns, Status.namespace)), self.handle_status)) registerStanzaPlugin(Iq, Status) registerStanzaPlugin(Status, JobStatus) registerStanzaPlugin(Status, PoolStatus)
def plugin_init(self): self.description = "Kestrel Jobs" self.backend = self.config.get('backend', None) self.submit_jid = self.config.get('jid', self.xmpp.jid) self.backend.tasks.clean() self.xmpp.registerHandler( Callback('Kestrel Job', MatchXPath('{%s}iq/{%s}job' % (self.xmpp.default_ns, Job.namespace)), self.handle_job)) registerStanzaPlugin(Iq, Job) self.xmpp.registerHandler( Callback('Kestrel Job Status', MatchXPath('{%s}iq/{%s}query' % (self.xmpp.default_ns, Status.namespace)), self.handle_status)) registerStanzaPlugin(Iq, Status) registerStanzaPlugin(Status, JobStatus) self.xmpp.add_event_handler('kestrel_job', self.queue_job) self.xmpp.add_event_handler('kestrel_job_cancel', self.cancel_job_iq) self.xmpp.add_event_handler('presence_unsubscribed', self.cancel_job_unsubscribe)
<server>localhost</server> <port>8888</port> <query xmlns="jabber:iq:roster"> <item jid="*****@*****.**" subscription="both" /> </query> </config> """ name = "config" namespace = "sleekxmpp:config" interfaces = set(("jid", "secret", "server", "port")) sub_interfaces = interfaces registerStanzaPlugin(Config, Roster) class ConfigComponent(ComponentXMPP): """ A simple SleekXMPP component that uses an external XML file to store its configuration data. To make testing that the component works, it will also echo messages sent to it. """ def __init__(self, config): """ Create a ConfigComponent.
<server>localhost</server> <port>8888</port> <query xmlns="jabber:iq:roster"> <item jid="*****@*****.**" subscription="both" /> </query> </config> """ name = "config" namespace = "sleekxmpp:config" interfaces = set(('jid', 'secret', 'server', 'port')) sub_interfaces = interfaces registerStanzaPlugin(Config, Roster) class ConfigComponent(ComponentXMPP): """ A simple SleekXMPP component that uses an external XML file to store its configuration data. To make testing that the component works, it will also echo messages sent to it. """ def __init__(self, config): """ Create a ConfigComponent.