summaryrefslogtreecommitdiff
path: root/plugins/filecat.py
blob: 5f404c98b42740bacdeb6bac396d5239d3334490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import plugins


FILECAT_DEFAULTS = {
    'filename': '/etc/hostname', 'title': 'CAT',
    'freq': 60, 'nofile': 'unavailable'
}


class PluginThread(plugins.PluginThreadCommon):
    def __init__(self, config):
        super(PluginThread, self).__init__(config, FILECAT_DEFAULTS)
        self.hide = False
        self.format_status(self.conf['title'], False)

    def main(self):
        try:
            with open(self.conf['filename'], 'r') as datafile:
                contents = datafile.read().strip()
            urgent = False
        except FileNotFoundError:
            contents = self.conf['nofile']
            urgent = True
        self.format_status(contents, urgent)