contrib: use pcall for luasocket in pop

This commit is contained in:
Adrian C. (anrxc) 2010-08-29 01:32:24 +02:00
parent b200a8073d
commit 88c3d0c11e
2 changed files with 6 additions and 4 deletions

View File

@ -13,7 +13,7 @@ require("vicious.contrib.mpc")
require("vicious.contrib.netcfg")
require("vicious.contrib.net")
require("vicious.contrib.ossvol")
--require("vicious.contrib.pop")
require("vicious.contrib.pop")
require("vicious.contrib.pulse")
require("vicious.contrib.rss")
require("vicious.contrib.sensors")

View File

@ -10,9 +10,11 @@
---------------------------------------------------
-- {{{ Grab environment
local setmetatable = setmetatable
local socket = require("socket")
local tonumber = tonumber
local setmetatable = setmetatable
local sock_avail, socket = pcall(function()
return require("socket")
end)
-- }}}
@ -22,7 +24,7 @@ module("vicious.contrib.pop")
-- {{{ POP3 count widget type
local function worker(format, warg)
if not warg or #warg ~= 4 then
if not sock_avail or (not warg or #warg ~= 4) then
return {"N/A"}
end