From d53d29a55605e291ab8a44c1a8e3d11aa0dd28ae Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 1 Jan 2020 22:42:30 +1000 Subject: Actually wait for the curl file before trying to process it. --- apt-panopticon.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'apt-panopticon.lua') diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 057fc40..ba4d408 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -934,6 +934,14 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them. end D('*>* Resumed coroutine NO LONGER waiting on - 0 < APT.checkExes(' .. downloadLock .. list.out .. '-' .. host .. '.log.txt') + -- Should not be needed, but maybe this is why sometimes I don't see the speeds, though the file is there when I look later. + local f = 'results/curl-' .. list.out .. "-" .. host .. ".log.txt" + while not APT.checkFile(f) do + D('*<* About to yield coroutine while waiting on - not APT.checkFile(' .. f .. ')') + coroutine.yield() + D('*>* Resumed coroutine while waiting on - not APT.checkFile(' .. f .. ')') + end + --[[ TODO - should try to figure out which server the file actually got downloaded from, and attribute the speed and errors to that server. Which means parsing the curl logs, not just a simple match(). Watch out for misplaced ^M, they don't all come at the end of the line. @@ -944,8 +952,8 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them. curl: (22) The requested URL returned error: 404 Not Found ]] local min, max, spd = 999999999999, 0 - if APT.checkFile("results/curl-" .. list.out .. "-" .. host .. ".log.txt") then - for l in io.lines("results/curl-" .. list.out .. "-" .. host .. ".log.txt") do + if APT.checkFile(f) then + for l in io.lines(f) do local speed, crrnt = l:match('^%c *%d+ +%d+k? +%d+ +%d+k? +%d+ +%d+ +(%d+k?) +%d+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +(%d+k?)') if nil ~= speed then if 'k' == speed:sub(-1, -1) then speed = speed:sub(1, -2) .. '000' end -- cgit v1.1