Revert r9252 for now. E2E was affected and task is shifted to next releas anyway. See #3694
This commit is contained in:
parent
347e8e1e5f
commit
55eed6bda6
|
@ -470,9 +470,8 @@ class CommandWindow:
|
||||||
assert action in ('execute', 'prev', 'next', 'complete')
|
assert action in ('execute', 'prev', 'next', 'complete')
|
||||||
|
|
||||||
stanza = xmpp.Iq(typ='set', to=self.jid)
|
stanza = xmpp.Iq(typ='set', to=self.jid)
|
||||||
cmdnode = stanza.addChild('command',
|
cmdnode = stanza.addChild('command', attrs={
|
||||||
namespace=xmpp.NS_COMMANDS,
|
'xmlns':xmpp.NS_COMMANDS,
|
||||||
attrs={
|
|
||||||
'node':self.commandnode,
|
'node':self.commandnode,
|
||||||
'action':action
|
'action':action
|
||||||
})
|
})
|
||||||
|
@ -502,9 +501,8 @@ class CommandWindow:
|
||||||
if self.sessionid and self.account.connection:
|
if self.sessionid and self.account.connection:
|
||||||
# we already have sessionid, so the service sent at least one reply.
|
# we already have sessionid, so the service sent at least one reply.
|
||||||
stanza = xmpp.Iq(typ='set', to=self.jid)
|
stanza = xmpp.Iq(typ='set', to=self.jid)
|
||||||
stanza.addChild('command',
|
stanza.addChild('command', attrs={
|
||||||
namespace=xmpp.NS_COMMANDS,
|
'xmlns':xmpp.NS_COMMANDS,
|
||||||
attrs={
|
|
||||||
'node':self.commandnode,
|
'node':self.commandnode,
|
||||||
'sessionid':self.sessionid,
|
'sessionid':self.sessionid,
|
||||||
'action':'cancel'
|
'action':'cancel'
|
||||||
|
|
|
@ -45,10 +45,10 @@ class AdHocCommand:
|
||||||
|
|
||||||
response = request.buildReply('result')
|
response = request.buildReply('result')
|
||||||
cmd = response.addChild('command', {
|
cmd = response.addChild('command', {
|
||||||
|
'xmlns': xmpp.NS_COMMANDS,
|
||||||
'sessionid': self.sessionid,
|
'sessionid': self.sessionid,
|
||||||
'node': self.commandnode,
|
'node': self.commandnode,
|
||||||
'status': status},
|
'status': status})
|
||||||
namespace=xmpp.NS_COMMANDS)
|
|
||||||
if defaultaction is not None or actions is not None:
|
if defaultaction is not None or actions is not None:
|
||||||
if defaultaction is not None:
|
if defaultaction is not None:
|
||||||
assert defaultaction in ('cancel', 'execute', 'prev', 'next',
|
assert defaultaction in ('cancel', 'execute', 'prev', 'next',
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ConnectionPubSub:
|
||||||
|
|
||||||
def send_pb_subscription_query(self, jid, cb, *args, **kwargs):
|
def send_pb_subscription_query(self, jid, cb, *args, **kwargs):
|
||||||
query = xmpp.Iq('get', to=jid)
|
query = xmpp.Iq('get', to=jid)
|
||||||
pb = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB)
|
pb = query.addChild('pubsub', {'xmlns': xmpp.NS_PUBSUB})
|
||||||
pb.addChild('subscriptions')
|
pb.addChild('subscriptions')
|
||||||
|
|
||||||
id = self.connection.send(query)
|
id = self.connection.send(query)
|
||||||
|
|
|
@ -286,7 +286,7 @@ class TestCommand(Command_Handler_Prototype):
|
||||||
reply = request.buildReply('result')
|
reply = request.buildReply('result')
|
||||||
form = DataForm(title='Select type of operation',data=['Use the combobox to select the type of calculation you would like to do, then click Next',DataField(name='calctype',label='Calculation Type',value=sessions[session]['data']['type'],options=[['circlediameter','Calculate the Diameter of a circle'],['circlearea','Calculate the area of a circle']],typ='list-single',required=1)])
|
form = DataForm(title='Select type of operation',data=['Use the combobox to select the type of calculation you would like to do, then click Next',DataField(name='calctype',label='Calculation Type',value=sessions[session]['data']['type'],options=[['circlediameter','Calculate the Diameter of a circle'],['circlearea','Calculate the area of a circle']],typ='list-single',required=1)])
|
||||||
replypayload = [Node('actions',attrs={'execute':'next'},payload=[Node('next')]),form]
|
replypayload = [Node('actions',attrs={'execute':'next'},payload=[Node('next')]),form]
|
||||||
reply.addChild(name='command',namespace=NS_COMMAND,attrs={'node':request.getTagAttr('command','node'),'sessionid':session,'status':'executing'},payload=replypayload)
|
reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':session,'status':'executing'},payload=replypayload)
|
||||||
self._owner.send(reply)
|
self._owner.send(reply)
|
||||||
raise NodeProcessed
|
raise NodeProcessed
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ class TestCommand(Command_Handler_Prototype):
|
||||||
reply = request.buildReply('result')
|
reply = request.buildReply('result')
|
||||||
form = DataForm(title = 'Enter the radius', data=['Enter the radius of the circle (numbers only)',DataField(label='Radius',name='radius',typ='text-single')])
|
form = DataForm(title = 'Enter the radius', data=['Enter the radius of the circle (numbers only)',DataField(label='Radius',name='radius',typ='text-single')])
|
||||||
replypayload = [Node('actions',attrs={'execute':'complete'},payload=[Node('complete'),Node('prev')]),form]
|
replypayload = [Node('actions',attrs={'execute':'complete'},payload=[Node('complete'),Node('prev')]),form]
|
||||||
reply.addChild(name='command',namespace=NS_COMMAND,attrs={'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'executing'},payload=replypayload)
|
reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'executing'},payload=replypayload)
|
||||||
self._owner.send(reply)
|
self._owner.send(reply)
|
||||||
raise NodeProcessed
|
raise NodeProcessed
|
||||||
|
|
||||||
|
@ -317,13 +317,13 @@ class TestCommand(Command_Handler_Prototype):
|
||||||
result = num*2*pi
|
result = num*2*pi
|
||||||
reply = result.buildReply(request)
|
reply = result.buildReply(request)
|
||||||
form = DataForm(typ='result',data=[DataField(label='result',name='result',value=result)])
|
form = DataForm(typ='result',data=[DataField(label='result',name='result',value=result)])
|
||||||
reply.addChild(name='command',namespace=NS_COMMAND,attrs={'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'completed'},payload=form)
|
reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'completed'},payload=form)
|
||||||
self._owner.send(reply)
|
self._owner.send(reply)
|
||||||
raise NodeProcessed
|
raise NodeProcessed
|
||||||
|
|
||||||
def cmdCancel(self,conn,request):
|
def cmdCancel(self,conn,request):
|
||||||
reply = request.buildReply('result')
|
reply = request.buildReply('result')
|
||||||
reply.addChild(name='command',namespace=NS_COMMAND,attrs={'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'cancelled'})
|
reply.addChild(name='command',attrs={'xmlns':NS_COMMAND,'node':request.getTagAttr('command','node'),'sessionid':request.getTagAttr('command','sessionid'),'status':'cancelled'})
|
||||||
self._owner.send(reply)
|
self._owner.send(reply)
|
||||||
del sessions[request.getTagAttr('command','sessionid')]
|
del sessions[request.getTagAttr('command','sessionid')]
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
## GNU General Public License for more details.
|
## GNU General Public License for more details.
|
||||||
|
|
||||||
# Based on:
|
# $Id: simplexml.py,v 1.27 2005/04/30 07:20:27 snakeru Exp $
|
||||||
# $Id: simplexml.py,v 1.33 2007/09/11 12:46:16 normanr Exp $
|
|
||||||
|
|
||||||
"""Simplexml module provides xmpppy library with all needed tools to handle XML nodes and XML streams.
|
"""Simplexml module provides xmpppy library with all needed tools to handle XML nodes and XML streams.
|
||||||
I'm personally using it in many other separate projects. It is designed to be as standalone as possible."""
|
I'm personally using it in many other separate projects. It is designed to be as standalone as possible."""
|
||||||
|
@ -78,7 +77,7 @@ class Node(object):
|
||||||
if isinstance(payload, basestring): payload=[payload]
|
if isinstance(payload, basestring): payload=[payload]
|
||||||
for i in payload:
|
for i in payload:
|
||||||
if isinstance(i, Node): self.addChild(node=i)
|
if isinstance(i, Node): self.addChild(node=i)
|
||||||
else: self.addData(i)
|
else: self.data.append(ustr(i))
|
||||||
|
|
||||||
def __str__(self,fancy=0):
|
def __str__(self,fancy=0):
|
||||||
""" Method used to dump node into textual representation.
|
""" Method used to dump node into textual representation.
|
||||||
|
@ -97,7 +96,7 @@ class Node(object):
|
||||||
for a in self.kids:
|
for a in self.kids:
|
||||||
if not fancy and (len(self.data)-1)>=cnt: s=s+XMLescape(self.data[cnt])
|
if not fancy and (len(self.data)-1)>=cnt: s=s+XMLescape(self.data[cnt])
|
||||||
elif (len(self.data)-1)>=cnt: s=s+XMLescape(self.data[cnt].strip())
|
elif (len(self.data)-1)>=cnt: s=s+XMLescape(self.data[cnt].strip())
|
||||||
if a: s = s + a.__str__(fancy and fancy+1)
|
s = s + a.__str__(fancy and fancy+1)
|
||||||
cnt=cnt+1
|
cnt=cnt+1
|
||||||
if not fancy and (len(self.data)-1) >= cnt: s = s + XMLescape(self.data[cnt])
|
if not fancy and (len(self.data)-1) >= cnt: s = s + XMLescape(self.data[cnt])
|
||||||
elif (len(self.data)-1) >= cnt: s = s + XMLescape(self.data[cnt].strip())
|
elif (len(self.data)-1) >= cnt: s = s + XMLescape(self.data[cnt].strip())
|
||||||
|
@ -109,36 +108,19 @@ class Node(object):
|
||||||
s = s + "</" + self.name + ">"
|
s = s + "</" + self.name + ">"
|
||||||
if fancy: s = s + "\n"
|
if fancy: s = s + "\n"
|
||||||
return s
|
return s
|
||||||
def getCDATA(self):
|
|
||||||
""" Serialise node, dropping all tags and leaving CDATA intact.
|
|
||||||
That is effectively kills all formatiing, leaving only text were contained in XML.
|
|
||||||
"""
|
|
||||||
s = ""
|
|
||||||
cnt = 0
|
|
||||||
if self.kids:
|
|
||||||
for a in self.kids:
|
|
||||||
s=s+self.data[cnt]
|
|
||||||
if a: s = s + a.getCDATA()
|
|
||||||
cnt=cnt+1
|
|
||||||
if (len(self.data)-1) >= cnt: s = s + self.data[cnt]
|
|
||||||
return s
|
|
||||||
def addChild(self, name=None, attrs={}, payload=[], namespace=None, node=None):
|
def addChild(self, name=None, attrs={}, payload=[], namespace=None, node=None):
|
||||||
""" If "node" argument is provided, adds it as child node. Else creates new node from
|
""" If "node" argument is provided, adds it as child node. Else creates new node from
|
||||||
the other arguments' values and adds it as well."""
|
the other arguments' values and adds it as well."""
|
||||||
if attrs.has_key('xmlns'):
|
|
||||||
raise AttributeError("Use namespace=x instead of attrs={'xmlns':x}")
|
|
||||||
if namespace: name=namespace+' '+name
|
if namespace: name=namespace+' '+name
|
||||||
if node:
|
if node:
|
||||||
newnode=node
|
newnode=node
|
||||||
node.parent = self
|
node.parent = self
|
||||||
else: newnode=Node(tag=name, parent=self, attrs=attrs, payload=payload)
|
else: newnode=Node(tag=name, parent=self, attrs=attrs, payload=payload)
|
||||||
self.kids.append(newnode)
|
self.kids.append(newnode)
|
||||||
self.data.append(u'')
|
|
||||||
return newnode
|
return newnode
|
||||||
def addData(self, data):
|
def addData(self, data):
|
||||||
""" Adds some CDATA to node. """
|
""" Adds some CDATA to node. """
|
||||||
self.data.append(ustr(data))
|
self.data.append(ustr(data))
|
||||||
self.kids.append(None)
|
|
||||||
def clearData(self):
|
def clearData(self):
|
||||||
""" Removes all CDATA from the node. """
|
""" Removes all CDATA from the node. """
|
||||||
self.data=[]
|
self.data=[]
|
||||||
|
@ -149,7 +131,7 @@ class Node(object):
|
||||||
""" Deletes the "node" from the node's childs list, if "node" is an instance.
|
""" Deletes the "node" from the node's childs list, if "node" is an instance.
|
||||||
Else deletes the first node that have specified name and (optionally) attributes. """
|
Else deletes the first node that have specified name and (optionally) attributes. """
|
||||||
if not isinstance(node, Node): node=self.getTag(node,attrs)
|
if not isinstance(node, Node): node=self.getTag(node,attrs)
|
||||||
self.kids[self.kids.index(node)]=None
|
self.kids.remove(node)
|
||||||
return node
|
return node
|
||||||
def getAttrs(self):
|
def getAttrs(self):
|
||||||
""" Returns all node's attributes as dictionary. """
|
""" Returns all node's attributes as dictionary. """
|
||||||
|
@ -178,9 +160,12 @@ class Node(object):
|
||||||
F.e. for "<node>text1<nodea/><nodeb/> text2</node>" will be returned list:
|
F.e. for "<node>text1<nodea/><nodeb/> text2</node>" will be returned list:
|
||||||
['text1', <nodea instance>, <nodeb instance>, ' text2']. """
|
['text1', <nodea instance>, <nodeb instance>, ' text2']. """
|
||||||
ret=[]
|
ret=[]
|
||||||
for i in range(max(len(self.data),len(self.kids))):
|
for i in range(len(self.kids)+len(self.data)+1):
|
||||||
if i < len(self.data) and self.data[i]: ret.append(self.data[i])
|
try:
|
||||||
if i < len(self.kids) and self.kids[i]: ret.append(self.kids[i])
|
if self.data[i]: ret.append(self.data[i])
|
||||||
|
except IndexError: pass
|
||||||
|
try: ret.append(self.kids[i])
|
||||||
|
except IndexError: pass
|
||||||
return ret
|
return ret
|
||||||
def getTag(self, name, attrs={}, namespace=None):
|
def getTag(self, name, attrs={}, namespace=None):
|
||||||
""" Filters all child nodes using specified arguments as filter.
|
""" Filters all child nodes using specified arguments as filter.
|
||||||
|
@ -210,7 +195,6 @@ class Node(object):
|
||||||
def iterTags(self, name, attrs={}, namespace=None):
|
def iterTags(self, name, attrs={}, namespace=None):
|
||||||
""" Iterate over all children using specified arguments as filter. """
|
""" Iterate over all children using specified arguments as filter. """
|
||||||
for node in self.kids:
|
for node in self.kids:
|
||||||
if not node: continue
|
|
||||||
if namespace is not None and namespace!=node.getNamespace(): continue
|
if namespace is not None and namespace!=node.getNamespace(): continue
|
||||||
if node.getName() == name:
|
if node.getName() == name:
|
||||||
for key in attrs.keys():
|
for key in attrs.keys():
|
||||||
|
@ -282,7 +266,7 @@ class Node(object):
|
||||||
class T:
|
class T:
|
||||||
""" Auxiliary class used to quick access to node's child nodes. """
|
""" Auxiliary class used to quick access to node's child nodes. """
|
||||||
def __init__(self,node): self.__dict__['node']=node
|
def __init__(self,node): self.__dict__['node']=node
|
||||||
def __getattr__(self,attr): return self.node.getTag(attr)
|
def __getattr__(self,attr): return self.node.setTag(attr)
|
||||||
def __setattr__(self,attr,val):
|
def __setattr__(self,attr,val):
|
||||||
if isinstance(val,Node): Node.__init__(self.node.setTag(attr),node=val)
|
if isinstance(val,Node): Node.__init__(self.node.setTag(attr),node=val)
|
||||||
else: return self.node.setTagData(attr,val)
|
else: return self.node.setTagData(attr,val)
|
||||||
|
|
Loading…
Reference in New Issue