SunPanel报错:attempt to index local 'obj' (a nil value)
故障现象
通过istore安装SunPanel,安装过程正常,但无法打开网页,并出现如下lua报错:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Runtime error Unhandled exception during request dispatching /usr/lib/lua/luci/ucodebridge.lua:23: /usr/lib/lua/luci/model/sunpanel.lua:13: attempt to index local 'obj' (a nil value)
In error(), file [C] called from function [anonymous function] (/usr/lib/lua/luci/ucodebridge.lua:23) called from function ((tail call)) In [anonymous function](), file /usr/share/ucode/luci/runtime.uc, line 148, byte 45: called from function [arrow function] (/usr/share/ucode/luci/dispatcher.uc:794:4) called from function render ([C]) called from function render_action (/usr/share/ucode/luci/dispatcher.uc:768:24) called from function run_action (/usr/share/ucode/luci/dispatcher.uc:795:4) called from function [anonymous function] (/usr/share/ucode/luci/dispatcher.uc:1003:48) called from anonymous function (/www/cgi-bin/luci:39:13)
` return lcall.call(modname, method, ...args);` Near here ----------------------------------------^
sunpanel.blocks = function() --[[ local f = io.popen("lsblk -s -f -b -o NAME,FSSIZE,MOUNTPOINT --json", "r") local vals = {} if f then local ret = f:read("*all") f:close() local obj = jsonc.parse(ret) for _, val in pairs(obj["blockdevices"]) do local fsize = val["fssize"] if fsize ~= nil and string.len(fsize) > 10 and val["mountpoint"] then -- fsize > 1G vals[#vals+1] = val["mountpoint"] end end end return vals ]]-- return {} end