Common code elimination run
This commit is contained in:
parent
4c45087a5b
commit
54c14658bc
@ -38,10 +38,6 @@ class ModsDeChecker(object):
|
|||||||
self.cj = http.cookiejar.CookieJar()
|
self.cj = http.cookiejar.CookieJar()
|
||||||
self.opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(self.cj))
|
self.opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(self.cj))
|
||||||
|
|
||||||
self.thread = threading.Thread(target=self.mainloop)
|
|
||||||
self.thread.daemon = True
|
|
||||||
self.thread.start()
|
|
||||||
|
|
||||||
def mainloop(self):
|
def mainloop(self):
|
||||||
while True:
|
while True:
|
||||||
unread = self.get_unread_count()
|
unread = self.get_unread_count()
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import urllib.request, urllib.error, urllib.parse
|
import urllib.request, urllib.error, urllib.parse
|
||||||
|
from threading import Thread
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
output = None
|
output = None
|
||||||
@ -23,12 +24,6 @@ class I3statusHandler(object):
|
|||||||
def register_module(self, module):
|
def register_module(self, module):
|
||||||
"""Register a new module."""
|
"""Register a new module."""
|
||||||
|
|
||||||
# check if module implemented the
|
|
||||||
# correct functions
|
|
||||||
#if not hasattr(module, 'output'):
|
|
||||||
# raise Exception("Module %s does not implement \
|
|
||||||
# all the needed functions!".format(module))
|
|
||||||
|
|
||||||
self.modules.append(module)
|
self.modules.append(module)
|
||||||
|
|
||||||
def print_line(self, message):
|
def print_line(self, message):
|
||||||
@ -55,6 +50,12 @@ class I3statusHandler(object):
|
|||||||
self.print_line(self.read_line())
|
self.print_line(self.read_line())
|
||||||
self.print_line(self.read_line())
|
self.print_line(self.read_line())
|
||||||
|
|
||||||
|
for module in self.modules:
|
||||||
|
if module.async:
|
||||||
|
module.thread = Thread(target=module.mainloop)
|
||||||
|
module.thread.daemon = True
|
||||||
|
module.thread.start()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
line, prefix = self.read_line(), ''
|
line, prefix = self.read_line(), ''
|
||||||
|
|
||||||
|
@ -43,10 +43,6 @@ class ThunderbirdMailChecker(object):
|
|||||||
dbus.mainloop.glib.threads_init()
|
dbus.mainloop.glib.threads_init()
|
||||||
self.context = loop.get_context()
|
self.context = loop.get_context()
|
||||||
|
|
||||||
self.thread = threading.Thread(target=self.mainloop)
|
|
||||||
self.thread.daemon = True
|
|
||||||
self.thread.start()
|
|
||||||
|
|
||||||
def mainloop(self):
|
def mainloop(self):
|
||||||
while True:
|
while True:
|
||||||
self.context.iteration(False)
|
self.context.iteration(False)
|
||||||
@ -75,4 +71,3 @@ class ThunderbirdMailChecker(object):
|
|||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
self.output = None
|
self.output = None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user