ENH check that rapl interfaces are readable
This commit is contained in:
parent
7ea7c7cea5
commit
77f8d23a03
|
@ -88,10 +88,19 @@ M.file_exists = function(path)
|
|||
return M.exit_code_cmd('stat '..path..' > /dev/null 2>&1') == 0
|
||||
end
|
||||
|
||||
M.file_readable = function(path)
|
||||
return M.exit_code_cmd('test -r '..path) == 0
|
||||
end
|
||||
|
||||
M.assert_file_exists = function(path)
|
||||
M.assertf(M.file_exists(path), '%s does not exist', path)
|
||||
end
|
||||
|
||||
M.assert_file_readable = function(path)
|
||||
M.assertf(M.file_exists(path), '%s does not exist', path)
|
||||
M.assertf(M.file_readable(path), '%s is not readable', path)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- conky object execution
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ return function(config, main_state, common, width, point)
|
|||
local mk_bars = function(y)
|
||||
local paths = pure.map_keys('path', config.fs_paths)
|
||||
local names = pure.map_keys('name', config.fs_paths)
|
||||
-- TODO this might not be enough (conky might actually need +x permissions
|
||||
-- to decend into the dir and read its contents)
|
||||
impure.each(i_o.assert_file_exists, paths)
|
||||
local CONKY_CMDS = pure.map(
|
||||
pure.partial(string.format, '${fs_used_perc %s}', true),
|
||||
|
|
|
@ -110,7 +110,6 @@ return function(update_freq, config, common, width, point)
|
|||
point = point,
|
||||
width = width,
|
||||
set_state = nil,
|
||||
-- TODO make sure these interfaces actually exist before trying to read them
|
||||
top = pure.concat(
|
||||
pure.map(mk_rate_blockspec, config.rapl_specs),
|
||||
{{mk_bat, config.battery ~= '', 0}}
|
||||
|
|
|
@ -84,7 +84,7 @@ local SYSFS_RAPL = '/sys/class/powercap'
|
|||
|
||||
M.intel_powercap_reader = function(dev)
|
||||
local uj = __string_format('%s/%s/energy_uj', SYSFS_RAPL, dev)
|
||||
i_o.assert_file_exists(uj)
|
||||
i_o.assert_file_readable(uj)
|
||||
return function()
|
||||
return read_micro(uj)
|
||||
end
|
||||
|
@ -97,7 +97,7 @@ local SYSFS_POWER = '/sys/class/power_supply'
|
|||
|
||||
local format_power_path = function(battery, property)
|
||||
local p = __string_format('%s/%s/%s', SYSFS_POWER, battery, property)
|
||||
i_o.assert_file_exists(p)
|
||||
i_o.assert_file_readable(p)
|
||||
return p
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue