Exemple #1
0
 def monitor_internet_state(self, timeout=30):
     elapsed_time = 0
     reported = False
     while elapsed_time < timeout:
         # check for pause or suspend
         self.pause_event.wait()
         if self.suspend: return
         # get internet state
         state = tools.internet_on()
         if state:
             if reported:
                 GObject.idle_add(self.parent.set_internet_state, state)
             return
         else:
             # print state
             self.debug(tools.print_internet_state(state), DebugLevel.High)
             if not reported:
                 GObject.idle_add(self.parent.set_internet_state, state)
                 reported = True
             # wait 1 second, before recheck
             time.sleep(1)
             elapsed_time += 1
     # if timeout reached
     if elapsed_time == timeout:
         self.pause()
         self.log('Unable to connect to the internet', LogType.Error)
Exemple #2
0
	def set_internet_state(self, state):
		if state:
			self.start_button.set_image(Gtk.Image(file=tools.get_full_path('icons/loader.gif')))
		else:
			self.log(tools.print_internet_state(state), LogType.Error)
			self.start_button.set_image(Gtk.Image(icon_name='network-error'))