comparison frontends/src/quick_frontend/quick_profile_manager.py @ 2091:f413bfc24458

bridge, quick_frontend: preparation for async bridge bridge can currently have sync and async methods. This commit prepare the transition to fully async bridges: - a new bridgeConnect method must be called to prepare the bridge - quick app, quick profile manager: changed sync calls to async ones - quick app: bridgeConnect can be called automatically or manually depending on connect_bridge parameter of QuickApp
author Goffi <goffi@goffi.org>
date Tue, 13 Dec 2016 22:27:48 +0100
parents 2daf7b4c6756
children 1d3f73e065e1
comparison
equal deleted inserted replaced
2090:52bd463e6fe7 2091:f413bfc24458
106 else: 106 else:
107 # a profile is not validated, we go to manual mode 107 # a profile is not validated, we go to manual mode
108 self._autoconnect=False 108 self._autoconnect=False
109 self.host.actionManager(data, callback=authenticate_cb, profile=profile) 109 self.host.actionManager(data, callback=authenticate_cb, profile=profile)
110 110
111 for profile_key in profile_keys: 111 def getProfileNameCb(profile):
112 profile = self.host.bridge.getProfileName(profile_key)
113 if not profile: 112 if not profile:
113 # FIXME: this method is not handling manual mode correclty anymore
114 # must be thought to be handled asynchronously
114 self._autoconnect = False # manual mode 115 self._autoconnect = False # manual mode
115 msg = _("Trying to plug an unknown profile key ({})".format(profile_key)) 116 msg = _("Trying to plug an unknown profile key ({})".format(profile_key))
116 log.warning(msg) 117 log.warning(msg)
117 self.showDialog(_("Profile plugging in error"), msg, 'error') 118 self.host.showDialog(_("Profile plugging in error"), msg, 'error')
118 break 119 else:
119 self.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=profile) 120 self.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=profile)
121
122 def getProfileNameEb(failure):
123 log.error(u"Can't retrieve profile name: {}".format(failure))
124
125 for profile_key in profile_keys:
126 self.host.bridge.getProfileName(profile_key, callback=getProfileNameCb, errback=getProfileNameEb)
120 127
121 128
122 def getParamError(self, dummy): 129 def getParamError(self, dummy):
123 self.host.showDialog(_(u"Error"), _("Can't get profile parameter"), 'error') 130 self.host.showDialog(_(u"Error"), _("Can't get profile parameter"), 'error')
124 131