comparison src/plugins/plugin_adhoc_dbus.py @ 916:1a759096ccbd

core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
author Goffi <goffi@goffi.org>
date Fri, 21 Mar 2014 16:27:09 +0100
parents 30ed86ea1c82
children 301b342c697a
comparison
equal deleted inserted replaced
915:6f96ee4d8cc0 916:1a759096ccbd
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _, D_ 20 from sat.core.i18n import _, D_
21 from sat.core.constants import Const as C
21 from logging import debug, info, warning, error 22 from logging import debug, info, warning, error
22 from twisted.words.protocols.jabber import jid 23 from twisted.words.protocols.jabber import jid
23 from twisted.internet import defer, reactor 24 from twisted.internet import defer, reactor
24 from wokkel import data_form 25 from wokkel import data_form
25 from lxml import etree 26 from lxml import etree
118 119
119 def _adHocDBusAddAuto(self, prog_name, allowed_jids, allowed_groups, allowed_magics, forbidden_jids, forbidden_groups, flags, profile_key): 120 def _adHocDBusAddAuto(self, prog_name, allowed_jids, allowed_groups, allowed_magics, forbidden_jids, forbidden_groups, flags, profile_key):
120 return self.adHocDBusAddAuto(prog_name, allowed_jids, allowed_groups, allowed_magics, forbidden_jids, forbidden_groups, flags, profile_key) 121 return self.adHocDBusAddAuto(prog_name, allowed_jids, allowed_groups, allowed_magics, forbidden_jids, forbidden_groups, flags, profile_key)
121 122
122 @defer.inlineCallbacks 123 @defer.inlineCallbacks
123 def adHocDBusAddAuto(self, prog_name, allowed_jids=None, allowed_groups=None, allowed_magics=None, forbidden_jids=None, forbidden_groups=None, flags=None, profile_key='@NONE@'): 124 def adHocDBusAddAuto(self, prog_name, allowed_jids=None, allowed_groups=None, allowed_magics=None, forbidden_jids=None, forbidden_groups=None, flags=None, profile_key=C.PROF_KEY_NONE):
124 bus_names = yield self._DBusListNames() 125 bus_names = yield self._DBusListNames()
125 bus_names = [bus_name for bus_name in bus_names if '.' + prog_name in bus_name] 126 bus_names = [bus_name for bus_name in bus_names if '.' + prog_name in bus_name]
126 if not bus_names: 127 if not bus_names:
127 info("Can't find any bus for [%s]" % prog_name) 128 info("Can't find any bus for [%s]" % prog_name)
128 return 129 return
147 profile_key = profile_key) 148 profile_key = profile_key)
148 149
149 defer.returnValue((bus_name, methods)) 150 defer.returnValue((bus_name, methods))
150 151
151 152
152 def _addCommand(self, adhoc_name, bus_name, methods, allowed_jids=None, allowed_groups=None, allowed_magics=None, forbidden_jids=None, forbidden_groups=None, flags=None, profile_key='@NONE@'): 153 def _addCommand(self, adhoc_name, bus_name, methods, allowed_jids=None, allowed_groups=None, allowed_magics=None, forbidden_jids=None, forbidden_groups=None, flags=None, profile_key=C.PROF_KEY_NONE):
153 if flags is None: 154 if flags is None:
154 flags = set() 155 flags = set()
155 156
156 def DBusCallback(command_elt, session_data, action, node, profile): 157 def DBusCallback(command_elt, session_data, action, node, profile):
157 actions = session_data.setdefault('actions',[]) 158 actions = session_data.setdefault('actions',[])