From: Jo-Philipp Wich
Date: Sun, 19 Jul 2009 00:24:58 +0000 (+0000)
Subject: convert luci.fs users to nixio.fs api
X-Git-Tag: 0.10.0~1333
X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8fcd841aa9af96c8a4a4d3c1a555d2d1ed42332c;p=oweals%2Fluci.git
convert luci.fs users to nixio.fs api
---
diff --git a/applications/luci-ddns/luasrc/controller/ddns.lua b/applications/luci-ddns/luasrc/controller/ddns.lua
index 6adbbb0ca..7a81d9adf 100644
--- a/applications/luci-ddns/luasrc/controller/ddns.lua
+++ b/applications/luci-ddns/luasrc/controller/ddns.lua
@@ -17,7 +17,7 @@ module("luci.controller.ddns", package.seeall)
function index()
require("luci.i18n")
luci.i18n.loadc("ddns")
- if not luci.fs.access("/etc/config/ddns") then
+ if not nixio.fs.access("/etc/config/ddns") then
return
end
@@ -29,4 +29,4 @@ function index()
local page = entry({"mini", "network", "ddns"}, cbi("ddns/ddnsmini", {autoapply=true}), luci.i18n.translate("ddns"), 60)
page.i18n = "ddns"
page.dependent = true
-end
\ No newline at end of file
+end
diff --git a/applications/luci-hd_idle/luasrc/controller/hd_idle.lua b/applications/luci-hd_idle/luasrc/controller/hd_idle.lua
index 5dfbe16ea..57ff10d7c 100644
--- a/applications/luci-hd_idle/luasrc/controller/hd_idle.lua
+++ b/applications/luci-hd_idle/luasrc/controller/hd_idle.lua
@@ -18,7 +18,7 @@ module("luci.controller.hd_idle", package.seeall)
function index()
require("luci.i18n")
luci.i18n.loadc("hd_idle")
- if not luci.fs.access("/etc/config/hd-idle") then
+ if not nixio.fs.access("/etc/config/hd-idle") then
return
end
diff --git a/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua b/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua
index b59df829f..60817db83 100644
--- a/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua
+++ b/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua
@@ -13,7 +13,7 @@ $Id$
]]--
-require("luci.fs")
+require("nixio.fs")
m = Map("hd-idle", translate("hd_idle"), translate("hd_idle_desc"))
@@ -24,8 +24,8 @@ s:option(Flag, "enabled", translate("enable", "Enable"))
disk = s:option(Value, "disk", translate("disk"))
disk.rmempty = true
-for _, dev in ipairs(luci.fs.glob("/dev/[sh]d[a-z]")) do
- disk:value(luci.fs.basename(dev))
+for _, dev in nixio.fs.glob("/dev/[sh]d[a-z]") do
+ disk:value(nixio.fs.basename(dev))
end
s:option(Value, "idle_time_interval", translate("idle_time_interval")).default = 10
diff --git a/applications/luci-initmgr/luasrc/controller/init.lua b/applications/luci-initmgr/luasrc/controller/init.lua
index fbbc7270f..c7ef43f83 100644
--- a/applications/luci-initmgr/luasrc/controller/init.lua
+++ b/applications/luci-initmgr/luasrc/controller/init.lua
@@ -15,7 +15,7 @@ $Id$
module("luci.controller.init", package.seeall)
function index()
- if not luci.fs.access("/etc/rc.common") then
+ if not nixio.fs.access("/etc/rc.common") then
return
end
diff --git a/applications/luci-mmc_over_gpio/luasrc/controller/mmc_over_gpio.lua b/applications/luci-mmc_over_gpio/luasrc/controller/mmc_over_gpio.lua
index 7beaa144f..57fe5ee38 100644
--- a/applications/luci-mmc_over_gpio/luasrc/controller/mmc_over_gpio.lua
+++ b/applications/luci-mmc_over_gpio/luasrc/controller/mmc_over_gpio.lua
@@ -18,7 +18,7 @@ module("luci.controller.mmc_over_gpio", package.seeall)
function index()
require("luci.i18n")
luci.i18n.loadc("mmc_over_gpio")
- if not luci.fs.access("/etc/config/mmc_over_gpio") then
+ if not nixio.fs.access("/etc/config/mmc_over_gpio") then
return
end
diff --git a/applications/luci-ntpc/luasrc/controller/ntpc.lua b/applications/luci-ntpc/luasrc/controller/ntpc.lua
index 929064468..0d656a48f 100644
--- a/applications/luci-ntpc/luasrc/controller/ntpc.lua
+++ b/applications/luci-ntpc/luasrc/controller/ntpc.lua
@@ -17,7 +17,7 @@ module("luci.controller.ntpc", package.seeall)
function index()
require("luci.i18n")
luci.i18n.loadc("ntpc")
- if not luci.fs.access("/etc/config/ntpclient") then
+ if not nixio.fs.access("/etc/config/ntpclient") then
return
end
diff --git a/applications/luci-olsr/luasrc/controller/olsr.lua b/applications/luci-olsr/luasrc/controller/olsr.lua
index 652f6b9d2..837873adf 100644
--- a/applications/luci-olsr/luasrc/controller/olsr.lua
+++ b/applications/luci-olsr/luasrc/controller/olsr.lua
@@ -1,7 +1,7 @@
module("luci.controller.olsr", package.seeall)
function index()
- if not luci.fs.access("/etc/config/olsrd") then
+ if not nixio.fs.access("/etc/config/olsrd") then
return
end
@@ -182,7 +182,7 @@ function fetch_txtinfo(otable)
local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable)
if #rawdata == 0 then
- if luci.fs.access("/proc/net/ipv6_route", "r") then
+ if nixio.fs.access("/proc/net/ipv6_route", "r") then
rawdata = luci.sys.httpget("http://[::1]:2006/"..otable)
if #rawdata == 0 then
return nil
diff --git a/applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua b/applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua
index 03f18a818..f81a4a4b4 100644
--- a/applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua
+++ b/applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua
@@ -13,9 +13,8 @@ You may obtain a copy of the License at
$Id$
]]--
-require("luci.fs")
-require("luci.ip")
-
+local ip = require "luci.ip"
+local fs = require "nixio.fs"
if arg[1] then
mp = Map("olsrd", translate("olsrd_plugins", "OLSR - Plugins"))
@@ -44,7 +43,7 @@ if arg[1] then
local function Cidr2IpMask(val)
if val then
for i = 1, #val do
- local cidr = luci.ip.IPv4(val[i]) or luci.ip.IPv6(val[i])
+ local cidr = ip.IPv4(val[i]) or ip.IPv6(val[i])
if cidr then
val[i] = cidr:network():string() .. " " .. cidr:mask():string()
end
@@ -59,9 +58,9 @@ if arg[1] then
local ip, mask = val[i]:gmatch("([^%s]+)%s+([^%s]+)")()
local cidr
if ip and mask and ip:match(":") then
- cidr = luci.ip.IPv6(ip, mask)
+ cidr = ip.IPv6(ip, mask)
elseif ip and mask then
- cidr = luci.ip.IPv4(ip, mask)
+ cidr = ip.IPv4(ip, mask)
end
if cidr then
@@ -220,7 +219,7 @@ else
)
-- create a loadplugin section for each found plugin
- for k, v in pairs(luci.fs.dir("/usr/lib")) do
+ for v in fs.dir("/usr/lib") do
if v:sub(1, 6) == "olsrd_" then
if not plugins[v] then
mpi.uci:section(
diff --git a/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua b/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua
index 834dceb24..13dfd1297 100644
--- a/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua
+++ b/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua
@@ -12,7 +12,6 @@ You may obtain a copy of the License at
$Id$
]]--
-require("luci.fs")
require("luci.ip")
diff --git a/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua b/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua
index 1d4cc4d7a..b3e22d480 100644
--- a/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua
+++ b/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua
@@ -12,7 +12,6 @@ You may obtain a copy of the License at
$Id$
]]--
-require("luci.fs")
require("luci.ip")
require("luci.model.uci")
diff --git a/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua b/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua
index 863be2f13..e71becd06 100644
--- a/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua
+++ b/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua
@@ -12,13 +12,9 @@ You may obtain a copy of the License at
$Id$
]]--
-require("luci.fs")
-require("luci.ip")
-require("luci.sys")
-require("luci.model.uci")
-
-
-local uci = luci.model.uci.cursor()
+local fs = require "nixio.fs"
+local sys = require "luci.sys"
+local uci = require "luci.model.uci".cursor()
local m = Map("openvpn", translate("openvpn"))
local s = m:section( TypedSection, "openvpn", translate("openvpn_overview"), translate("openvpn_overview_desc") )
@@ -74,13 +70,11 @@ s:option( Flag, "enable", translate("openvpn_enable") )
local active = s:option( DummyValue, "_active", translate("openvpn_active") )
function active.cfgvalue(self, section)
- if luci.fs.isfile("/var/run/openvpn_%s.pid" % section) then
- local pid = io.lines("/var/run/openvpn_%s.pid" % section)()
- if pid and #pid > 0 and tonumber(pid) ~= nil then
- return (luci.sys.process.signal(pid, 0))
- and translatef("openvpn_active_yes", pid)
- or translate("openvpn_active_no")
- end
+ local pid = fs.readfile("/var/run/openvpn_%s.pid" % section)
+ if pid and #pid > 0 and tonumber(pid) ~= nil then
+ return (sys.process.signal(pid, 0))
+ and translatef("openvpn_active_yes", pid)
+ or translate("openvpn_active_no")
end
return translate("openvpn_active_no")
end
diff --git a/applications/luci-p910nd/luasrc/controller/p910nd.lua b/applications/luci-p910nd/luasrc/controller/p910nd.lua
index 75b2693d4..13167013c 100644
--- a/applications/luci-p910nd/luasrc/controller/p910nd.lua
+++ b/applications/luci-p910nd/luasrc/controller/p910nd.lua
@@ -18,7 +18,7 @@ module("luci.controller.p910nd", package.seeall)
function index()
require("luci.i18n")
luci.i18n.loadc("p910nd")
- if not luci.fs.access("/etc/config/p910nd") then
+ if not nixio.fs.access("/etc/config/p910nd") then
return
end
diff --git a/applications/luci-polipo/luasrc/controller/polipo.lua b/applications/luci-polipo/luasrc/controller/polipo.lua
index 949f80a62..3d9f7d1ff 100644
--- a/applications/luci-polipo/luasrc/controller/polipo.lua
+++ b/applications/luci-polipo/luasrc/controller/polipo.lua
@@ -14,7 +14,7 @@ $Id$
module("luci.controller.polipo", package.seeall)
function index()
- if not luci.fs.access("/etc/config/polipo") then
+ if not nixio.fs.access("/etc/config/polipo") then
return
end
diff --git a/applications/luci-qos/luasrc/controller/qos.lua b/applications/luci-qos/luasrc/controller/qos.lua
index 970dd3d60..af9b11499 100644
--- a/applications/luci-qos/luasrc/controller/qos.lua
+++ b/applications/luci-qos/luasrc/controller/qos.lua
@@ -14,7 +14,7 @@ $Id$
module("luci.controller.qos", package.seeall)
function index()
- if not luci.fs.access("/etc/config/qos") then
+ if not nixio.fs.access("/etc/config/qos") then
return
end
@@ -26,4 +26,4 @@ function index()
local page = entry({"mini", "network", "qos"}, cbi("qos/qosmini", {autoapply=true}), "QoS")
page.i18n = "qos"
page.dependent = true
-end
\ No newline at end of file
+end
diff --git a/applications/luci-qos/luasrc/model/cbi/qos/qos.lua b/applications/luci-qos/luasrc/model/cbi/qos/qos.lua
index 22dfbea5f..ec450cf6e 100644
--- a/applications/luci-qos/luasrc/model/cbi/qos/qos.lua
+++ b/applications/luci-qos/luasrc/model/cbi/qos/qos.lua
@@ -11,7 +11,10 @@ You may obtain a copy of the License at
$Id$
]]--
-require("luci.tools.webadmin")
+
+local wa = require "luci.tools.webadmin"
+local fs = require "nixio.fs"
+
m = Map("qos")
s = m:section(TypedSection, "interface", translate("interfaces"))
@@ -46,19 +49,19 @@ t.default = "Normal"
srch = s:option(Value, "srchost")
srch.rmempty = true
srch:value("", translate("all"))
-luci.tools.webadmin.cbi_add_knownips(srch)
+wa.cbi_add_knownips(srch)
dsth = s:option(Value, "dsthost")
dsth.rmempty = true
dsth:value("", translate("all"))
-luci.tools.webadmin.cbi_add_knownips(dsth)
+wa.cbi_add_knownips(dsth)
l7 = s:option(ListValue, "layer7", translate("service"))
l7.rmempty = true
l7:value("", translate("all"))
-local pats = luci.fs.dir("/etc/l7-protocols")
+local pats = fs.dir("/etc/l7-protocols")
if pats then
- for i,f in ipairs(pats) do
+ for f in pats do
if f:sub(-4) == ".pat" then
l7:value(f:sub(1, #f-4))
end
diff --git a/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua b/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua
index ec93694c2..cb7968264 100644
--- a/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua
+++ b/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua
@@ -12,7 +12,10 @@ You may obtain a copy of the License at
$Id$
]]--
-require("luci.tools.webadmin")
+
+local wa = require "luci.tools.webadmin"
+local fs = require "nixio.fs"
+
m = Map("qos")
s = m:section(NamedSection, "wan", "interface", translate("m_n_inet"))
@@ -37,19 +40,19 @@ t.default = "Normal"
srch = s:option(Value, "srchost")
srch.rmempty = true
srch:value("", translate("all"))
-luci.tools.webadmin.cbi_add_knownips(srch)
+wa.cbi_add_knownips(srch)
dsth = s:option(Value, "dsthost")
dsth.rmempty = true
dsth:value("", translate("all"))
-luci.tools.webadmin.cbi_add_knownips(dsth)
+wa.cbi_add_knownips(dsth)
l7 = s:option(ListValue, "layer7", translate("service"))
l7.rmempty = true
l7:value("", translate("all"))
-local pats = luci.fs.dir("/etc/l7-protocols")
+local pats = fs.dir("/etc/l7-protocols")
if pats then
- for i,f in ipairs(pats) do
+ for f in pats do
if f:sub(-4) == ".pat" then
l7:value(f:sub(1, #f-4))
end
diff --git a/applications/luci-samba/luasrc/controller/samba.lua b/applications/luci-samba/luasrc/controller/samba.lua
index 75cb65a0b..c2d5d849a 100644
--- a/applications/luci-samba/luasrc/controller/samba.lua
+++ b/applications/luci-samba/luasrc/controller/samba.lua
@@ -15,7 +15,7 @@ $Id$
module("luci.controller.samba", package.seeall)
function index()
- if not luci.fs.access("/etc/config/samba") then
+ if not nixio.fs.access("/etc/config/samba") then
return
end
require("luci.i18n")
diff --git a/applications/luci-splash/luasrc/view/admin_status/splash.htm b/applications/luci-splash/luasrc/view/admin_status/splash.htm
index 99395200d..4151c66c3 100644
--- a/applications/luci-splash/luasrc/view/admin_status/splash.htm
+++ b/applications/luci-splash/luasrc/view/admin_status/splash.htm
@@ -18,6 +18,8 @@ local utl = require "luci.util"
local ipt = require "luci.sys.iptparser".IptParser()
local uci = require "luci.model.uci".cursor_state()
local wat = require "luci.tools.webadmin"
+local fs = require "nixio.fs"
+
local clients = { }
local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime") or 1) * 60 * 60
local leasefile = "/tmp/dhcp.leases"
@@ -94,7 +96,7 @@ uci:foreach("luci_splash", "blacklist",
end
end)
-if luci.fs.access(leasefile) then
+if fs.access(leasefile) then
for l in io.lines(leasefile) do
local time, mac, ip, name = l:match("^(%d+) (%S+) (%S+) (%S+)")
if time and mac and ip then
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool.lua b/applications/luci-statistics/luasrc/statistics/rrdtool.lua
index 911b38bff..eb5c266b0 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool.lua
@@ -22,7 +22,8 @@ require("luci.statistics.i18n")
require("luci.model.uci")
require("luci.util")
require("luci.sys")
-require("luci.fs")
+
+local fs = require "nixio.fs"
Graph = luci.util.class()
@@ -96,7 +97,7 @@ function Graph._rrdtool( self, def, rrd )
-- prepare directory
local dir = def[1]:gsub("/[^/]+$","")
- luci.fs.mkdir( dir, true )
+ fs.mkdirr( dir )
-- construct commandline
local cmdline = "rrdtool graph"
@@ -500,7 +501,7 @@ function Graph.render( self, plugin, plugin_instance )
-- check for a whole graph handler
local plugin_def = "luci.statistics.rrdtool.definitions." .. plugin
- local stat, def = luci.util.copcall( require, plugin_def )
+ local stat, def = pcall( require, plugin_def )
if stat and def and type(def.rrdargs) == "function" then
@@ -539,7 +540,7 @@ function Graph.render( self, plugin, plugin_instance )
-- check for data type handler
local dtype_def = plugin_def .. "." .. dtype
- local stat, def = luci.util.copcall( require, dtype_def )
+ local stat, def = pcall( require, dtype_def )
if stat and def and type(def.rrdargs) == "function" then
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua
index 7e0b60534..883261351 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua
@@ -16,7 +16,6 @@ $Id$
module("luci.statistics.rrdtool.definitions", package.seeall)
require("luci.util")
-require("luci.fs")
Instance = luci.util.class()
diff --git a/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm b/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm
index 54ba2b0e2..13e52257e 100644
--- a/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm
+++ b/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm
@@ -22,7 +22,7 @@ about open tcp connections, interface traffic, iptables rules etc.%>
<%:stat_networkplugins_installed Installed network plugins:%>
<% for plugin, desc in pairs(plugins) do %>
- <% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
+ <% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
- <%=desc%>
<% end %>
<% end %>
diff --git a/applications/luci-statistics/luasrc/view/admin_statistics/outputplugins.htm b/applications/luci-statistics/luasrc/view/admin_statistics/outputplugins.htm
index e79e2f49f..ef9ae23b5 100644
--- a/applications/luci-statistics/luasrc/view/admin_statistics/outputplugins.htm
+++ b/applications/luci-statistics/luasrc/view/admin_statistics/outputplugins.htm
@@ -23,7 +23,7 @@ and to transmit the data over the network to other collectd instances.%>
<%:stat_outputplugins_installed Installed output plugins:%>
<% for plugin, desc in pairs(plugins) do %>
- <% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
+ <% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
- <%=desc%>
<% end %>
<% end %>
diff --git a/applications/luci-statistics/luasrc/view/admin_statistics/systemplugins.htm b/applications/luci-statistics/luasrc/view/admin_statistics/systemplugins.htm
index 0c1b2b52b..0e801c791 100644
--- a/applications/luci-statistics/luasrc/view/admin_statistics/systemplugins.htm
+++ b/applications/luci-statistics/luasrc/view/admin_statistics/systemplugins.htm
@@ -19,7 +19,7 @@ $Id$
<%:stat_systemplugins_desc System plugins collecting values about system state and ressource usage on the device.:%>