Mercurial > libervia-desktop-kivy
diff cagou/plugins/plugin_wid_remote.py @ 312:772c170b47a9
Python3 port:
/!\ Cagou now runs with Python 3.6+
Port has been done in the same way as for backend (check backend commit b2d067339de3
message for details).
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 13 Aug 2019 19:14:22 +0200 |
parents | e2afbec1d178 |
children | e2b51663d8b8 |
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_remote.py Mon Aug 05 11:21:54 2019 +0200 +++ b/cagou/plugins/plugin_wid_remote.py Tue Aug 13 19:14:22 2019 +0200 @@ -41,13 +41,13 @@ PLUGIN_INFO = { - "name": _(u"remote control"), + "name": _("remote control"), "main": "RemoteControl", - "description": _(u"universal remote control"), - "icon_symbol": u"signal", + "description": _("universal remote control"), + "icon_symbol": "signal", } -NOTE_TITLE = _(u"Media Player Remote Control") +NOTE_TITLE = _("Media Player Remote Control") class RemoteItemWidget(ItemWidget): @@ -66,7 +66,7 @@ class MediaPlayerControlWidget(BoxLayout): main_wid = properties.ObjectProperty() remote_item = properties.ObjectProperty() - status = properties.OptionProperty(u"play", options=(u"play", u"pause", u"stop")) + status = properties.OptionProperty("play", options=("play", "pause", "stop")) title = properties.StringProperty() identity = properties.StringProperty() command = properties.DictProperty() @@ -84,34 +84,34 @@ try: setattr(self, prop.lower(), ui_tpl.widgets[prop].value) except KeyError: - log.warning(_(u"Missing field: {name}").format(name=prop)) + log.warning(_("Missing field: {name}").format(name=prop)) playback_status = self.ui_tpl.widgets['PlaybackStatus'].value - if playback_status == u"Playing": - self.status = u"pause" - elif playback_status == u"Paused": - self.status = u"play" - elif playback_status == u"Stopped": - self.status = u"play" + if playback_status == "Playing": + self.status = "pause" + elif playback_status == "Paused": + self.status = "play" + elif playback_status == "Stopped": + self.status = "play" else: G.host.addNote( title=NOTE_TITLE, - message=_(u"Unknown playback status: playback_status") + message=_("Unknown playback status: playback_status") .format(playback_status=playback_status), level=C.XMLUI_DATA_LVL_WARNING) self.commands = {v:k for k,v in ui_tpl.widgets['command'].options} def adHocRunCb(self, xmlui_raw): ui_tpl = template_xmlui.create(G.host, xmlui_raw) - data = {xmlui.XMLUIPanel.escape(u"media_player"): self.remote_item.node, - u"session_id": ui_tpl.session_id} + data = {xmlui.XMLUIPanel.escape("media_player"): self.remote_item.node, + "session_id": ui_tpl.session_id} G.host.bridge.launchAction( ui_tpl.submit_id, data, self.profile, callback=self.updateUI, errback=self.main_wid.errback) def on_remote_item(self, __, remote): - NS_MEDIA_PLAYER = G.host.ns_map[u"mediaplayer"] - G.host.bridge.adHocRun(unicode(remote.device_jid), NS_MEDIA_PLAYER, self.profile, + NS_MEDIA_PLAYER = G.host.ns_map["mediaplayer"] + G.host.bridge.adHocRun(str(remote.device_jid), NS_MEDIA_PLAYER, self.profile, callback=self.adHocRunCb, errback=self.main_wid.errback) @@ -121,15 +121,15 @@ except KeyError: G.host.addNote( title=NOTE_TITLE, - message=_(u"{command} command is not managed").format(command=command), + message=_("{command} command is not managed").format(command=command), level=C.XMLUI_DATA_LVL_WARNING) else: - data = {xmlui.XMLUIPanel.escape(u"command"): cmd_value, - u"session_id": self.ui_tpl.session_id} + data = {xmlui.XMLUIPanel.escape("command"): cmd_value, + "session_id": self.ui_tpl.session_id} # hidden values are normally transparently managed by XMLUIPanel # but here we have to add them by hand hidden = {xmlui.XMLUIPanel.escape(k):v - for k,v in self.ui_tpl.hidden.iteritems()} + for k,v in self.ui_tpl.hidden.items()} data.update(hidden) G.host.bridge.launchAction( self.ui_tpl.submit_id, data, self.profile, @@ -140,9 +140,9 @@ class RemoteDeviceWidget(DeviceWidget): def xmluiCb(self, data, cb_id, profile): - if u'xmlui' in data: + if 'xmlui' in data: xml_ui = xmlui.create( - G.host, data[u'xmlui'], callback=self.xmluiCb, profile=profile) + G.host, data['xmlui'], callback=self.xmluiCb, profile=profile) if isinstance(xml_ui, xmlui.XMLUIDialog): self.main_wid.showRootWidget() xml_ui.show() @@ -151,7 +151,7 @@ self.main_wid.layout.add_widget(xml_ui) else: if data: - log.warning(_(u"Unhandled data: {data}").format(data=data)) + log.warning(_("Unhandled data: {data}").format(data=data)) self.main_wid.showRootWidget() def onClose(self, __, reason): @@ -167,7 +167,7 @@ def do_item_action(self, touch): self.main_wid.layout.clear_widgets() - G.host.bridge.adHocRun(unicode(self.entity_jid), u'', self.profile, + G.host.bridge.adHocRun(str(self.entity_jid), '', self.profile, callback=self.adHocRunCb, errback=self.main_wid.errback) @@ -194,7 +194,7 @@ """Generic errback which add a warning note and go back to root widget""" G.host.addNote( title=NOTE_TITLE, - message=_(u"Can't use remote control: {reason}").format(reason=failure_), + message=_("Can't use remote control: {reason}").format(reason=failure_), level=C.XMLUI_DATA_LVL_WARNING) self.showRootWidget() @@ -218,8 +218,8 @@ self.show_devices(found) def adHocRemotesGetEb(self, failure_, found): - G.host.errback(failure_, title=_(u"discovery error"), - message=_(u"can't check remote controllers: {msg}")) + G.host.errback(failure_, title=_("discovery error"), + message=_("can't check remote controllers: {msg}")) found.insert(0, []) if len(found) == 2: self.show_devices(found) @@ -236,8 +236,8 @@ self.show_devices(found) def _discoFindByFeaturesEb(self, failure_, found): - G.host.errback(failure_, title=_(u"discovery error"), - message=_(u"can't check devices: {msg}")) + G.host.errback(failure_, title=_("discovery error"), + message=_("can't check devices: {msg}")) found.append(({}, {}, {})) if len(found) == 2: self.show_devices(found) @@ -247,9 +247,9 @@ try: namespace = self.host.ns_map['commands'] except KeyError: - msg = _(u"can't find ad-hoc commands namespace, is the plugin running?") + msg = _("can't find ad-hoc commands namespace, is the plugin running?") log.warning(msg) - G.host.addNote(_(u"missing plugin"), msg, C.XMLUI_DATA_LVL_ERROR) + G.host.addNote(_("missing plugin"), msg, C.XMLUI_DATA_LVL_ERROR) return self.host.bridge.discoFindByFeatures( [namespace], [], False, True, True, True, False, self.profile, @@ -259,7 +259,7 @@ def show_devices(self, found): remotes_data, (entities_services, entities_own, entities_roster) = found if remotes_data: - title = _(u"media players remote controls") + title = _("media players remote controls") self.stack_layout.add_widget(CategorySeparator(text=title)) for remote_data in remotes_data: @@ -268,14 +268,14 @@ self.stack_layout.add_widget(wid) for entities_map, title in ((entities_services, - _(u'services')), + _('services')), (entities_own, - _(u'your devices')), + _('your devices')), (entities_roster, - _(u'your contacts devices'))): + _('your contacts devices'))): if entities_map: self.stack_layout.add_widget(CategorySeparator(text=title)) - for entity_str, entity_ids in entities_map.iteritems(): + for entity_str, entity_ids in entities_map.items(): entity_jid = jid.JID(entity_str) item = RemoteDeviceWidget( self, entity_jid, Identities(entity_ids)) @@ -286,4 +286,4 @@ size_hint=(1, 1), halign='center', text_size=self.size, - text=_(u"No sharing device found"))) + text=_("No sharing device found")))