Пример #1
0
 def _UpdateLastNextCheck( self ):
     
     if self._last_checked == 0:
         
         last_checked_text = 'initial check has not yet occured'
         
     else:
         
         last_checked_text = 'last checked ' + HydrusData.ConvertTimestampToPrettySync( self._last_checked )
         
     
     self._last_checked_st.SetLabelText( last_checked_text )
     
     periodic_next_check_time = self._last_checked + self._period.GetValue()
     error_next_check_time = self._last_error + HC.UPDATE_DURATION
     
     if self._check_now:
         
         next_check_text = 'next check as soon as manage subscriptions dialog is closed'
         
     elif error_next_check_time > periodic_next_check_time:
         
         next_check_text = 'due to an error, next check ' + HydrusData.ConvertTimestampToPrettyPending( error_next_check_time )
         
     else:
         
         next_check_text = 'next check ' + HydrusData.ConvertTimestampToPrettyPending( periodic_next_check_time )
         
     
     self._next_check_st.SetLabelText( next_check_text )
Пример #2
0
    def BandwidthOK(self):

        with self._lock:

            if self._ObeysBandwidth():

                result = self.engine.bandwidth_manager.TryToStartRequest(
                    self._network_contexts)

                if result:

                    self._bandwidth_tracker.ReportRequestUsed()

                else:

                    bandwidth_waiting_duration = self.engine.bandwidth_manager.GetWaitingEstimate(
                        self._network_contexts)

                    will_override = self._bandwidth_manual_override_delayed_timestamp is not None

                    override_coming_first = False

                    if will_override:

                        override_waiting_duration = HydrusData.GetNow(
                        ) - self._bandwidth_manual_override_delayed_timestamp

                        override_coming_first = override_waiting_duration < bandwidth_waiting_duration

                    if override_coming_first:

                        waiting_duration = override_waiting_duration

                        prefix = 'overriding bandwidth '

                        waiting_str = HydrusData.ConvertTimestampToPrettyPending(
                            self._bandwidth_manual_override_delayed_timestamp)

                    else:

                        waiting_duration = bandwidth_waiting_duration

                        prefix = 'bandwidth free '

                        waiting_str = HydrusData.ConvertTimestampToPrettyPending(
                            HydrusData.GetNow() + waiting_duration)

                    if waiting_duration < 2:

                        waiting_str = 'imminently'

                    self._status_text = prefix + waiting_str + u'\u2026'

                    if waiting_duration > 1200:

                        self._Sleep(30)

                    elif waiting_duration > 120:

                        self._Sleep(10)

                    elif waiting_duration > 10:

                        self._Sleep(1)

                return result

            else:

                self._bandwidth_tracker.ReportRequestUsed()

                self.engine.bandwidth_manager.ReportRequestUsed(
                    self._network_contexts)

                return True