2016-11-28 13:48:11 +02:00
|
|
|
import plugins
|
2016-10-23 01:53:02 +03:00
|
|
|
import psutil
|
|
|
|
|
|
|
|
|
2019-03-28 12:21:15 +02:00
|
|
|
DISK_DEFAULTS = {'partition': '/', 'problem': 80, 'freq': 15}
|
|
|
|
|
|
|
|
|
2016-11-28 13:48:11 +02:00
|
|
|
class PluginThread(plugins.PluginThreadCommon):
|
2017-12-16 01:55:28 +02:00
|
|
|
def __init__(self, config):
|
2019-03-28 12:21:15 +02:00
|
|
|
super(PluginThread, self).__init__(config, DISK_DEFAULTS)
|
2019-07-05 18:24:46 +03:00
|
|
|
if 'title' not in self.conf:
|
|
|
|
self.conf['title'] = self.conf['partition']
|
2016-10-23 01:53:02 +03:00
|
|
|
|
|
|
|
def main(self):
|
2017-12-16 01:55:28 +02:00
|
|
|
du_stat = psutil.disk_usage(self.conf['partition'])
|
|
|
|
if du_stat.percent >= self.conf['problem']:
|
2016-10-31 14:10:30 +02:00
|
|
|
self.hide = False
|
|
|
|
self.status['urgent'] = True
|
|
|
|
else:
|
|
|
|
self.hide = True
|
|
|
|
self.status['urgent'] = False
|
2019-07-08 14:19:05 +03:00
|
|
|
|
2019-07-05 18:24:46 +03:00
|
|
|
status = '{:.2f}G'.format(du_stat.free / 2**30)
|
|
|
|
self.format_status(status)
|