comparison src/plugins/plugin_import.py @ 2436:b52e78cc86ed

plugin import: fixed deserialisation of pubsub service
author Goffi <goffi@goffi.org>
date Wed, 15 Nov 2017 21:15:42 +0100
parents 8b37a62336c3
children 0046283a285d
comparison
equal deleted inserted replaced
2435:49884c579266 2436:b52e78cc86ed
21 from sat.core.constants import Const as C 21 from sat.core.constants import Const as C
22 from sat.core.log import getLogger 22 from sat.core.log import getLogger
23 log = getLogger(__name__) 23 log = getLogger(__name__)
24 from twisted.internet import defer 24 from twisted.internet import defer
25 from sat.core import exceptions 25 from sat.core import exceptions
26 from twisted.words.protocols.jabber import jid
26 from functools import partial 27 from functools import partial
27 import collections 28 import collections
28 import uuid 29 import uuid
29 import json 30 import json
30 31
114 for option in import_handler.JSON_OPTIONS: 115 for option in import_handler.JSON_OPTIONS:
115 try: 116 try:
116 options[option] = json.loads(options[option]) 117 options[option] = json.loads(options[option])
117 except ValueError: 118 except ValueError:
118 raise exceptions.DataError(_(u'invalid json option: {name}').format(name=option)) 119 raise exceptions.DataError(_(u'invalid json option: {name}').format(name=option))
119 return self.doImport(client, import_handler, unicode(name), unicode(location), options, pubsub_service or None, pubsub_node or None) 120 pubsub_service = jid.JID(pubsub_service) if pubsub_service else None
121 return self.doImport(client, import_handler, unicode(name), unicode(location), options, pubsub_service, pubsub_node or None)
120 122
121 @defer.inlineCallbacks 123 @defer.inlineCallbacks
122 def doImport(self, client, import_handler, name, location, options=None, pubsub_service=None, pubsub_node=None): 124 def doImport(self, client, import_handler, name, location, options=None, pubsub_service=None, pubsub_node=None):
123 """Import data 125 """Import data
124 126