diff options
author | Von Random <von@vdrandom.org> | 2018-11-02 20:15:33 +0300 |
---|---|---|
committer | Von Random <von@vdrandom.org> | 2018-11-02 20:15:33 +0300 |
commit | 05f83d818b69531a810600d9e9cbe6799bdb96b9 (patch) | |
tree | 0701611bd07a115a5bd415591b82a914330a6a21 | |
parent | 412f2de6b7a81dd023b92b3abead528b3c1dfd50 (diff) |
fucking-great-advice added
-rw-r--r-- | plugins/fga.py | 21 | ||||
-rw-r--r-- | plugins/pacman.py | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/plugins/fga.py b/plugins/fga.py new file mode 100644 index 0000000..ccda9d5 --- /dev/null +++ b/plugins/fga.py @@ -0,0 +1,21 @@ +# TODO: tidy up the fucking code +import plugins +import requests + + +URI = 'http://fucking-great-advice.ru/api/random' +class PluginThread(plugins.PluginThreadCommon): + def __init__(self, config): + defaults = {'freq': 120} + super(PluginThread, self).__init__(config, defaults) + + + def main(self): + try: + req = requests.get(URI, timeout=2) + advice = req.json()['text'] if req.status_code == 200 else 'N/A' + except requests.exceptions.Timeout: + advice = 'N/A (timeout)' + except requests.exceptions.ConnectionError: + advice = 'N/A (offline)' + self.status['full_text'] = advice diff --git a/plugins/pacman.py b/plugins/pacman.py index 853bb6b..7a9586c 100644 --- a/plugins/pacman.py +++ b/plugins/pacman.py @@ -17,6 +17,6 @@ class PluginThread(plugins.PluginThreadCommon): self.status['urgent'] = count >= self.conf['problem'] def main(self): - # TODO: this is an ugly hack, fix it with subprocess.Popen asap + # TODO: this is an ugly hack, fix it with subprocess.Popen someday updates = subprocess.getoutput('/usr/bin/pacman -Qu').count(" -> ") self.format_status(updates) |