examples: Add support for node configuration to pubsub_client.
This commit is contained in:
parent
dd7f67d10d
commit
92ea131721
1 changed files with 10 additions and 3 deletions
|
@ -21,7 +21,7 @@ class PubsubClient(slixmpp.ClientXMPP):
|
||||||
self.register_plugin('xep_0059')
|
self.register_plugin('xep_0059')
|
||||||
self.register_plugin('xep_0060')
|
self.register_plugin('xep_0060')
|
||||||
|
|
||||||
self.actions = ['nodes', 'create', 'delete',
|
self.actions = ['nodes', 'create', 'delete', 'get_configure',
|
||||||
'publish', 'get', 'retract',
|
'publish', 'get', 'retract',
|
||||||
'purge', 'subscribe', 'unsubscribe']
|
'purge', 'subscribe', 'unsubscribe']
|
||||||
|
|
||||||
|
@ -65,6 +65,13 @@ class PubsubClient(slixmpp.ClientXMPP):
|
||||||
except XMPPError as error:
|
except XMPPError as error:
|
||||||
logging.error('Could not delete node %s: %s', self.node, error.format())
|
logging.error('Could not delete node %s: %s', self.node, error.format())
|
||||||
|
|
||||||
|
def get_configure(self):
|
||||||
|
try:
|
||||||
|
configuration_form = yield from self['xep_0060'].get_configure_form(self.pubsub_server, self.node)
|
||||||
|
logging.info('Configure form received from node %s: %s', self.node, configuration_form)
|
||||||
|
except XMPPError as error:
|
||||||
|
logging.error('Could not retrieve configure form from node %s: %s', self.node, error.format())
|
||||||
|
|
||||||
def publish(self):
|
def publish(self):
|
||||||
payload = ET.fromstring("<test xmlns='test'>%s</test>" % self.data)
|
payload = ET.fromstring("<test xmlns='test'>%s</test>" % self.data)
|
||||||
try:
|
try:
|
||||||
|
@ -118,7 +125,7 @@ if __name__ == '__main__':
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
parser.version = '%%prog 0.1'
|
parser.version = '%%prog 0.1'
|
||||||
parser.usage = "Usage: %%prog [options] <jid> " + \
|
parser.usage = "Usage: %%prog [options] <jid> " + \
|
||||||
'nodes|create|delete|purge|subscribe|unsubscribe|publish|retract|get' + \
|
'nodes|create|delete|get_configure|purge|subscribe|unsubscribe|publish|retract|get' + \
|
||||||
' [<node> <data>]'
|
' [<node> <data>]'
|
||||||
|
|
||||||
parser.add_argument("-q","--quiet", help="set logging to ERROR",
|
parser.add_argument("-q","--quiet", help="set logging to ERROR",
|
||||||
|
@ -139,7 +146,7 @@ if __name__ == '__main__':
|
||||||
help="password to use")
|
help="password to use")
|
||||||
|
|
||||||
parser.add_argument("server")
|
parser.add_argument("server")
|
||||||
parser.add_argument("action", choices=["nodes", "create", "delete", "purge", "subscribe", "unsubscribe", "publish", "retract", "get"])
|
parser.add_argument("action", choices=["nodes", "create", "delete", "get_configure", "purge", "subscribe", "unsubscribe", "publish", "retract", "get"])
|
||||||
parser.add_argument("node", nargs='?')
|
parser.add_argument("node", nargs='?')
|
||||||
parser.add_argument("data", nargs='?')
|
parser.add_argument("data", nargs='?')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue