Skip to content

Commit

Permalink
also color old paths
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrinux committed Jul 9, 2018
1 parent 49f3c5f commit 0cf4bf8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
8 changes: 6 additions & 2 deletions py3status/modules/file_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,16 @@ def file_status(self):

if self.thresholds:
self.py3.threshold_get_color(count_path, 'path')
self.py3.threshold_get_color(count_path, 'paths')

return {
'cached_until': self.py3.time_in(self.cache_timeout),
'full_text': self.py3.safe_format(
'cached_until':
self.py3.time_in(self.cache_timeout),
'full_text':
self.py3.safe_format(
self.format, {
'path': count_path,
'paths': count_path,
'format_path': format_path
}
)
Expand Down
33 changes: 25 additions & 8 deletions py3status/modules/vnstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"""

from __future__ import division # python2 compatibility

STRING_ERROR = 'vnstat: returned wrong'
STRING_NOT_INSTALLED = 'not installed'

Expand Down Expand Up @@ -73,10 +74,16 @@ def post_config_hook(self):
if not self.py3.check_commands('vnstat'):
raise Exception(STRING_NOT_INSTALLED)

self.value_format = "{value:%s.%sf} {unit}" % (self.left_align, self.precision)
self.value_format = "{value:%s.%sf} {unit}" % (self.left_align,
self.precision)
# list of units, first one - value/initial_multi, second - value/1024,
# third - value/1024^2, etc...
self.units = ["kb", "mb", "gb", "tb", ]
self.units = [
"kb",
"mb",
"gb",
"tb",
]

def _divide_and_format(self, value):
# Divide a value and return formatted string
Expand All @@ -91,12 +98,15 @@ def _divide_and_format(self, value):
def vntstat(self):
def filter_stat():
# Get statistics in list of lists of words
out = self.py3.command_output(["vnstat", "--exportdb"]).splitlines()
out = self.py3.command_output(["vnstat",
"--exportdb"]).splitlines()
for x in out:
if x.startswith("{};0;".format(self.statistics_type)):
return x

try:
type, number, ts, rxm, txm, rxk, txk, fill = filter_stat().split(";")
type, number, ts, rxm, txm, rxk, txk, fill = filter_stat().split(
";")
except:
return {
'cached_until': self.py3.time_in(self.cache_timeout),
Expand All @@ -108,7 +118,12 @@ def filter_stat():

up = (int(txm) * 1024 + int(txk)) * 1024
down = (int(rxm) * 1024 + int(rxk)) * 1024
stat = {"up": up, "down": down, "total": up + down}
stat = {
"up": up,
"down": down,
"total": up + down,
"estimated": int(fill) * 1024
}

keys = list(self.coloring.keys())
keys.sort()
Expand All @@ -120,9 +135,11 @@ def filter_stat():

response['full_text'] = self.py3.safe_format(
self.format,
dict(total=self._divide_and_format(stat['total']),
up=self._divide_and_format(stat['up']),
down=self._divide_and_format(stat['down'])))
dict(
total=self._divide_and_format(stat['total']),
up=self._divide_and_format(stat['up']),
down=self._divide_and_format(stat['down']),
estimated=self._divide_and_format(stat['estimated'])))
return response


Expand Down

0 comments on commit 0cf4bf8

Please sign in to comment.