summaryrefslogtreecommitdiff
path: root/alfred
diff options
context:
space:
mode:
authorGui Iribarren <gui@altermundi.net>2016-08-08 00:35:35 +0200
committerGui Iribarren <gui@altermundi.net>2017-03-28 16:41:13 -0300
commit7b851e5f19e4b4112531bc39b0b7392e34859177 (patch)
treef272fbe3a14b423c5691c940b4401e7ef11735ca /alfred
parente912da66254eaf98e0a053815d2b1b437753d5bd (diff)
alfred: bat-hosts.lua: 'alfred -r' can fail with no output, so retry 3 times
Signed-off-by: Gui Iribarren <gui@altermundi.net>
Diffstat (limited to 'alfred')
-rw-r--r--alfred/Makefile2
-rw-r--r--alfred/files/bat-hosts.lua29
2 files changed, 18 insertions, 13 deletions
diff --git a/alfred/Makefile b/alfred/Makefile
index 8b2d9e3..b0dffbc 100644
--- a/alfred/Makefile
+++ b/alfred/Makefile
@@ -12,7 +12,7 @@ include $(TOPDIR)/rules.mk
#
PKG_NAME:=alfred
PKG_VERSION:=2017.0
-PKG_RELEASE:=0
+PKG_RELEASE:=1
PKG_MD5SUM:=2e9ae897b1d477f14d06389eb7c1f97b
PKG_HASH:=f8d6d83d2ce30b2238354ce12073285387c0f4ca1a28060390ff50b411b50fa8
diff --git a/alfred/files/bat-hosts.lua b/alfred/files/bat-hosts.lua
index 8648caf..f9fe586 100644
--- a/alfred/files/bat-hosts.lua
+++ b/alfred/files/bat-hosts.lua
@@ -87,19 +87,24 @@ end
local function receive_bat_hosts()
-- read raw chunks from alfred, convert them to a nested table and call write_bat_hosts
- local fd = io.popen("alfred -r " .. type_id)
- --[[ this command returns something like
- { "54:e6:fc:b9:cb:37", "00:11:22:33:44:55 ham_wlan0\x0a00:22:33:22:33:22 ham_eth0\x0a" },
- { "90:f6:52:bb:ec:57", "00:22:33:22:33:23 spam\x0a" },
- ]]--
-
- if fd then
- local output = fd:read("*a")
- if output then
- assert(loadstring("rows = {" .. output .. "}"))()
- write_bat_hosts(rows)
+-- "alfred -r" can fail in slave nodes (returns empty stdout), so:
+-- check output is not null before writing /tmp/bat-hosts, and retry 3 times before giving up.
+ for n = 1, 3 do
+ local fd = io.popen("alfred -r " .. type_id)
+ --[[ this command returns something like
+ { "54:e6:fc:b9:cb:37", "00:11:22:33:44:55 ham_wlan0\x0a00:22:33:22:33:22 ham_eth0\x0a" },
+ { "90:f6:52:bb:ec:57", "00:22:33:22:33:23 spam\x0a" },
+ ]]--
+
+ if fd then
+ local output = fd:read("*a")
+ fd:close()
+ if output and output ~= "" then
+ assert(loadstring("rows = {" .. output .. "}"))()
+ write_bat_hosts(rows)
+ break
+ end
end
- fd:close()
end
end