def remaining_api_calls(self): hits = self.api_call('rate_limit_status', _("Retrieving API calls"), report_success=False) resetTime = misc.SecondsToString(hits['reset_time_in_seconds'] - round(time.time())) output.speak( _("You have %s API calls left. They will reset to %d calls in %s." ) % (hits['remaining_hits'], hits['hourly_limit'], resetTime), True)
def on_schedule_message(self): if self.delay: output.speak(_("Resetting currently scheduled item."), True) dlg = ScheduleDialog(parent=self, title=_("Schedule message")) if dlg.ShowModal() != wx.ID_OK: return output.speak(_("Canceled."), True) self.delay = dlg.get_time() output.speak( _("Delaying for %s") % misc.SecondsToString(self.delay), True) self.message.SetFocus()
def interact(self, index=None): if not self[index].running and self[index].start_time: self[index].reset() self[index].start() output.speak(_("Stopwatch reset and counting."), True) elif not self[index].running: self[index].start() output.speak(_("Stopwatch counting."), True) else: self[index].stop() output.speak( _("Stopwatch stopped at %s." % misc.SecondsToString(self[index].elapsed_time(), 3)), True)
def get_elapsed(self, item=None): return misc.SecondsToString(item.elapsed_time(), 3)
def delay_action(interval, function, action=None, *args, **kwargs): if not action: action = _("action") output.speak(_("Delaying %s for %s.") % (action, misc.SecondsToString(interval))) delay(interval, function, *args, **kwargs)
def remaining_api_calls(self): limit = int(self.api_call('get_lastfunction_header', _("Retrieving API calls"), report_success=False, header='x-rate-limit-limit')) remaining = self.api_call('get_lastfunction_header', _("Retrieving API calls"), report_success=False, header='x-rate-limit-remaining') resets_in = int(self.api_call('get_lastfunction_header', _("Retrieving API calls"), report_success=False, header='x-rate-limit-reset')) resetTime = misc.SecondsToString(resets_in - round(time.time())) output.speak(_("You have %s API calls left. They will reset to %d calls in %s.") % (remaining, limit, resetTime), True)
def get_remaining(self, item): return misc.SecondsToString(item.remaining_time(), 1)