mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-28 15:30:08 -04:00
Merge branch 'master' of github.com:MightyPirates/OpenComputers into MC1.7
This commit is contained in:
commit
9933b85e24
@ -10,11 +10,13 @@ if not component.isAvailable("internet") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local args, options = shell.parse(...)
|
local args, options = shell.parse(...)
|
||||||
|
options.q = options.q or options.Q
|
||||||
|
|
||||||
if #args < 1 then
|
if #args < 1 then
|
||||||
io.write("Usage: wget [-fq] <url> [<filename>]\n")
|
io.write("Usage: wget [-fq] <url> [<filename>]\n")
|
||||||
io.write(" -f: Force overwriting existing files.\n")
|
io.write(" -f: Force overwriting existing files.\n")
|
||||||
io.write(" -q: Quiet mode - no status messages.")
|
io.write(" -q: Quiet mode - no status messages.\n")
|
||||||
|
io.write(" -Q: Superquiet mode - no error messages.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -33,22 +35,28 @@ if not filename then
|
|||||||
end
|
end
|
||||||
filename = text.trim(filename)
|
filename = text.trim(filename)
|
||||||
if filename == "" then
|
if filename == "" then
|
||||||
io.stderr:write("could not infer filename, please specify one")
|
if not options.Q then
|
||||||
return
|
io.stderr:write("could not infer filename, please specify one")
|
||||||
|
end
|
||||||
|
return nil, "missing target filename" -- for programs using wget as a function
|
||||||
end
|
end
|
||||||
filename = shell.resolve(filename)
|
filename = shell.resolve(filename)
|
||||||
|
|
||||||
if fs.exists(filename) then
|
if fs.exists(filename) then
|
||||||
if not options.f or not os.remove(filename) then
|
if not options.f or not os.remove(filename) then
|
||||||
io.stderr:write("file already exists")
|
if not options.Q then
|
||||||
return
|
io.stderr:write("file already exists")
|
||||||
|
end
|
||||||
|
return nil, "file already exists" -- for programs using wget as a function
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local f, reason = io.open(filename, "wb")
|
local f, reason = io.open(filename, "wb")
|
||||||
if not f then
|
if not f then
|
||||||
io.stderr:write("failed opening file for writing: " .. reason)
|
if not options.Q then
|
||||||
return
|
io.stderr:write("failed opening file for writing: " .. reason)
|
||||||
|
end
|
||||||
|
return nil, "failed opening file for writing: " .. reason -- for programs using wget as a function
|
||||||
end
|
end
|
||||||
|
|
||||||
if not options.q then
|
if not options.q then
|
||||||
@ -56,8 +64,21 @@ if not options.q then
|
|||||||
end
|
end
|
||||||
local result, response = pcall(internet.request, url)
|
local result, response = pcall(internet.request, url)
|
||||||
if result then
|
if result then
|
||||||
for chunk in response do
|
local result, reason = pcall(function()
|
||||||
f:write(chunk)
|
for chunk in response do
|
||||||
|
f:write(chunk)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
if not result then
|
||||||
|
if not options.q then
|
||||||
|
io.stderr:write("failed.\n")
|
||||||
|
end
|
||||||
|
f:close()
|
||||||
|
fs.remove(filename)
|
||||||
|
if not options.Q then
|
||||||
|
io.stderr:write("HTTP request failed: " .. reason .. "\n")
|
||||||
|
end
|
||||||
|
return nil, reason -- for programs using wget as a function
|
||||||
end
|
end
|
||||||
if not options.q then
|
if not options.q then
|
||||||
io.write("success.\n")
|
io.write("success.\n")
|
||||||
@ -73,5 +94,9 @@ else
|
|||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
fs.remove(filename)
|
fs.remove(filename)
|
||||||
io.stderr:write("HTTP request failed: " .. response .. "\n")
|
if not options.Q then
|
||||||
|
io.stderr:write("HTTP request failed: " .. response .. "\n")
|
||||||
|
end
|
||||||
|
return nil, response -- for programs using wget as a function
|
||||||
end
|
end
|
||||||
|
return true -- for programs using wget as a function
|
@ -37,7 +37,7 @@ trait IndustrialCraft2 extends Common with IEnergySink {
|
|||||||
|
|
||||||
@Optional.Method(modid = "IC2")
|
@Optional.Method(modid = "IC2")
|
||||||
def injectEnergyUnits(directionFrom: ForgeDirection, amount: Double) =
|
def injectEnergyUnits(directionFrom: ForgeDirection, amount: Double) =
|
||||||
tryChangeBuffer(directionFrom, amount * Settings.ratioIC2) / Settings.ratioIC2
|
amount - tryChangeBuffer(directionFrom, amount * Settings.ratioIC2) / Settings.ratioIC2
|
||||||
|
|
||||||
@Optional.Method(modid = "IC2")
|
@Optional.Method(modid = "IC2")
|
||||||
def getMaxSafeInput = Integer.MAX_VALUE
|
def getMaxSafeInput = Integer.MAX_VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user