Browse Source

fucking-great-advice added

master
Von Random 4 years ago
parent
commit
05f83d818b
  1. 21
      plugins/fga.py
  2. 2
      plugins/pacman.py

21
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

2
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)

Loading…
Cancel
Save