Last active
August 29, 2015 13:56
-
-
Save TamasBarta/8968204 to your computer and use it in GitHub Desktop.
Revisions
-
TamasBarta revised this gist
Apr 10, 2015 . No changes.There are no files selected for viewing
-
TamasBarta revised this gist
Apr 10, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,4 +55,4 @@ def main(self): gtk.main() checker = Checker() checker.main() -
TamasBarta revised this gist
Feb 13, 2014 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class Checker: def internet_on(self): try: response=urllib2.urlopen('http://74.125.228.100',timeout=2) return True except urllib2.URLError as err: pass except socket.timeout as err: pass @@ -36,9 +36,9 @@ def check(self): self.a.set_icon('ubuntuone-client-error') n = pynotify.Notification('Internetkapcsolat ellenőrző', body, 'network') n.show() gtk.timeout_add(3000, self.check) def main(self): # print what @@ -51,7 +51,7 @@ def main(self): m.append(mQuit) self.a.set_menu(m) gtk.timeout_add(3000, self.check) gtk.main() checker = Checker() -
TamasBarta created this gist
Feb 13, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ #!/usr/bin/python # -*- coding: UTF-8 -*- import urllib2 import appindicator import pynotify import gtk from concurrent import futures import socket class Checker: last_check = True a = None def internet_on(self): try: response=urllib2.urlopen('http://74.125.228.100',timeout=1) return True except urllib2.URLError as err: pass except socket.timeout as err: pass return False def quit(self, item): gtk.main_quit(); def check(self): current_check = self.internet_on() if self.last_check != current_check: self.last_check = current_check pynotify.init('netcheckindicator') if current_check: body = 'Van internetkapcsolat' self.a.set_icon('ubuntuone-client-idle') else: body = 'Nincs internetkapcsolat' self.a.set_icon('ubuntuone-client-error') n = pynotify.Notification('Internetkapcsolat ellenőrző', body, 'notification-message-im') n.show() gtk.timeout_add(1000, self.check) def main(self): # print what self.a = appindicator.Indicator('netcheckindicator', 'ubuntuone-client-idle', appindicator.CATEGORY_APPLICATION_STATUS) self.a.set_status( appindicator.STATUS_ACTIVE ) m = gtk.Menu() mQuit = gtk.MenuItem('Kilépés') mQuit.show() mQuit.connect('activate', self.quit) m.append(mQuit) self.a.set_menu(m) gtk.timeout_add(1000, self.check) gtk.main() checker = Checker() checker.main()