fetch specific file id from server

This commit is contained in:
Simon Voordouw 2017-04-11 17:04:57 +02:00
parent fe5b2ec306
commit 25aba526b4
2 changed files with 6 additions and 3 deletions

View File

@ -191,7 +191,8 @@ function M.fetch_POST(request, response)
local socket = printer:getId()
local remote = settings.get('gcode_server')
io.popen("print-fetch.lua " .. socket .. " " .. remote)
local id = request:get("id")
io.popen("print-fetch.lua " .. socket .. " " .. remote .. " " .. id)
end
--requires: gcode(string) (the gcode to be appended)

View File

@ -10,7 +10,9 @@ local remote = arg[2]
local finished = false
local info = JSON:decode(io.popen("wget -qO - " .. remote .. "/info/"):read("*a"))
local id = arg[3]
local info = JSON:decode(io.popen("wget -qO - " .. remote .. "/info/" .. id):read("*a"))
local current_line = 0
local total_lines = tonumber(info["lines"])
@ -18,7 +20,7 @@ local started = false
while(not finished)
do
local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. current_line)
local f = io.popen("wget -qO - " .. remote .. "/fetch/" .. id .. "/" .. current_line)
local line = f:read()
while line ~= nil do
printer:appendGcode(line)