Checks for internet connection before running backends.
This commit is contained in:
parent
0b507807bc
commit
3496a7bae5
@ -1,4 +1,5 @@
|
|||||||
from i3pystatus import SettingsBase, IntervalModule, formatp
|
from i3pystatus import SettingsBase, IntervalModule, formatp
|
||||||
|
from i3pystatus.core.util import internet
|
||||||
|
|
||||||
|
|
||||||
class Backend(SettingsBase):
|
class Backend(SettingsBase):
|
||||||
@ -41,8 +42,10 @@ class Updates(IntervalModule):
|
|||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
("backends", "Required list of backends used to check for updates."),
|
("backends", "Required list of backends used to check for updates."),
|
||||||
("format", "String shown when updates are availible. May contain formatters."),
|
("format", "String shown when updates are availible. "
|
||||||
("format_no_updates", "String that is shown if no updates are available. If not set the module will be hidden if no updates are available."),
|
"May contain formatters."),
|
||||||
|
("format_no_updates", "String that is shown if no updates are available."
|
||||||
|
" If not set the module will be hidden if no updates are available."),
|
||||||
"color",
|
"color",
|
||||||
"color_no_updates",
|
"color_no_updates",
|
||||||
("interval", "Default interval is set to one hour."),
|
("interval", "Default interval is set to one hour."),
|
||||||
@ -63,6 +66,10 @@ class Updates(IntervalModule):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
if not internet():
|
||||||
|
self.logger.info("Updates: No internet connection.")
|
||||||
|
return
|
||||||
|
|
||||||
updates_count = 0
|
updates_count = 0
|
||||||
for backend in self.backends:
|
for backend in self.backends:
|
||||||
updates_count += backend.updates
|
updates_count += backend.updates
|
||||||
|
Loading…
Reference in New Issue
Block a user