def _watch_fd(self, fd): for l in iter(fd.readline, ''): # os-independent form of stripping newline from the end of # the fine. We want to add it manually bellow line = l.splitlines()[0] schedule_in_main_thread(self.emit, 'read-line', line) schedule_in_main_thread(self.feed, line + '\r\n')
def _on_error(self, data=None): log.info('Failed to report bug: %r count=%d' % (data, self._count)) if self._count < _N_TRIES: self.submit() else: schedule_in_main_thread(self.emit, 'failed', data) self._count += 1
def next_step(self): # We already sent the details, but may still be on the same step. # Also, if the user didn't choose to "register now", respect his # decision if not self.model.register_now or self.wizard.link_request_done: return FinishInstallationStep(self.wizard) webapi = WebService() webapi.link_registration(self.model.name, self.model.email, self.model.phone, callback=lambda r: schedule_in_main_thread( self._on_response_done, r), errback=lambda e: schedule_in_main_thread( self._on_response_error, e)) self.send_progress.show() self.send_progress.set_text(_('Sending...')) self.send_progress.set_pulse_step(0.05) self.wizard.next_button.set_sensitive(False) GLib.timeout_add(50, self._pulse) # Cancel the request after 30 seconds without a reply GLib.timeout_add(30000, self._cancel_request) # Stay on the same step while sending the details return self
def _on_error(self, data=None): log.info("Failed to report bug: %r count=%d" % (data, self._count)) if self._count < _N_TRIES: self.submit() else: schedule_in_main_thread(self.emit, "failed", data) self._count += 1
def refresh_and_notify(self): """Refresh the resource status and notify for changes""" old_status, old_reason = self.status, self.reason self.refresh() if (self.status, self.reason) != (old_status, old_reason): # This is running on another so schedule the emit in the main one schedule_in_main_thread(self.emit, "status-changed", self.status, self.reason)
def refresh_and_notify(self): """Refresh the resource status and notify for changes""" old_status, old_reason = self.status, self.reason self.refresh() if (self.status, self.reason) != (old_status, old_reason): # This is running on another so schedule the emit in the main one schedule_in_main_thread( self.emit, 'status-changed', self.status, self.reason)
def _handle_action(self, action): try: with self._lock: retval = action.callback() except Exception as e: retval = e finally: self.running_action = None schedule_in_main_thread(self.emit, "action-finished", action, retval) return retval
def _refresh_and_notify(self, resources=None, force=False): with self._lock: old_status = self.status resources = resources or self._iter_resources() for resource in resources: resource.refresh_and_notify() status = self.status if status != old_status or force: # This is running on another so schedule the emit in the main one schedule_in_main_thread(self.emit, "status-changed", status)
def _refresh_and_notify(self, resources=None, force=False): with self._lock: old_status = self.status resources = resources or self._iter_resources() for resource in resources: resource.refresh_and_notify() status = self.status if status != old_status or force: # This is running on another so schedule the emit in the main one schedule_in_main_thread(self.emit, 'status-changed', status)
def _handle_action(self, action): try: with self._lock: retval = action.callback() except Exception as e: retval = e finally: self.running_action = None schedule_in_main_thread(self.emit, 'action-finished', action, retval) return retval
def next_step(self): # We already sent the details, but may still be on the same step. # Also, if the user didn't choose to "register now", respect his # decision if not self.model.register_now or self.wizard.link_request_done: return FinishInstallationStep(self.wizard) webapi = WebService() webapi.link_registration( self.model.name, self.model.email, self.model.phone, callback=lambda r: schedule_in_main_thread(self._on_response_done, r), errback=lambda e: schedule_in_main_thread(self._on_response_error, e)) self.send_progress.show() self.send_progress.set_text(_('Sending...')) self.send_progress.set_pulse_step(0.05) self.wizard.next_button.set_sensitive(False) GLib.timeout_add(50, self._pulse) # Cancel the request after 30 seconds without a reply GLib.timeout_add(30000, self._cancel_request) # Stay on the same step while sending the details return self
def _handle_action(self, action): schedule_in_main_thread(self.emit, 'action-started', action) try: with self._lock: retval = action.callback() except Exception as e: retval = e schedule_in_main_thread( lambda: warning(_('An error happened when executing "%s"') % (action.label, ), str(retval)) and False) finally: self.running_action = None schedule_in_main_thread(self.emit, 'action-finished', action, retval) return retval
def _register_link(self): running = self._proxy.check_running() if running: pin = self.pin.read() try: rv = self._proxy.call('register_link', pin) except ServerError as e: msg = _("An error happened when trying to register to Stoq.Link") schedule_in_main_thread(self._error, msg, str(e)) else: log.info("register_link succedded. Retval: %s", rv) # If no exception happened, that mens that the registration # has succeeded. schedule_in_main_thread(self._set_done) else: # TODO: Maybe we should add a link pointing to instructions # on how to get and install the stoq-server package? msg = _("Could not find an instance of Stoq Server running.") schedule_in_main_thread(self._error, msg)
def _register_link(self): running = self._proxy.check_running() if running: pin = self.pin.read() try: rv = yield self._proxy.call('register_link', pin) except ServerError as e: msg = _( "An error happened when trying to register to Stoq.Link") schedule_in_main_thread(self._error, msg, str(e)) else: log.info("register_link succedded. Retval: %s", rv) # If no exception happened, that mens that the registration # has succeeded. schedule_in_main_thread(self._set_done) else: # TODO: Maybe we should add a link pointing to instructions # on how to get and install the stoq-server package? msg = _("Could not find an instance of Stoq Server running.") schedule_in_main_thread(self._error, msg)
def _on_feedback_reply(self, details): log.info("Feedback details: %s" % (details, )) api.user_settings.set('feedback-email', self.model.email) self.retval = self.model schedule_in_main_thread(self.main_dialog.close)
def _setup_daemon(self): daemon = start_daemon() assert daemon.running self._calendar.set_daemon_uri(daemon.server_uri) schedule_in_main_thread(self._calendar.load)
def _on_success(self, data): log.info("Finished sending bugreport: %r" % (data,)) schedule_in_main_thread(self.emit, "submitted", data)
def _on_success(self, data): log.info('Finished sending bugreport: %r' % (data, )) schedule_in_main_thread(self.emit, 'submitted', data)
def _threaded_render(self): self.render() schedule_in_main_thread(self._threaded_render_done)