update libraries

This commit is contained in:
Kirigaya Kazuto 2018-02-13 11:59:23 +08:00
parent db306383c2
commit 1f15b7529a
3 changed files with 34 additions and 17 deletions

View File

@ -1,19 +1,17 @@
local component=require("component")
function DownloadFromGitHub(RepoName,Branch,FileAddress)
local hwtable=component.list()
local function doRealDownload(url)
local hwtable=component.list("internet")
local found=false
for k,v in pairs(hwtable) do
if(v=="internet") then
found=true
end
found=true
end
if(not found) then
error("The downloader requires an Internet card.")
end
local url="https://raw.githubusercontent.com/" .. RepoName .. "/" .. Branch .. "/" .. FileAddress
local handle=component.internet.request(url)
local ans=""
while true do
local tmp=handle.read()
@ -25,6 +23,11 @@ function DownloadFromGitHub(RepoName,Branch,FileAddress)
return ans
end
function DownloadFromGitHub(RepoName,Branch,FileAddress)
local url="https://raw.githubusercontent.com/" .. RepoName .. "/" .. Branch .. "/" .. FileAddress
return doRealDownload(url)
end
function DownloadFromOCS(FileAddress)
return DownloadFromGitHub("Kiritow/OpenComputerScripts","master",FileAddress)
end
@ -43,5 +46,4 @@ function WriteStringToFile(StringValue,FileName,IsAppend)
handle:close()
return true,"Success"
end
end

View File

@ -1,7 +1,8 @@
-- From Downloader
---------------------------- Begin of From Downloader
local component=require("component")
function DownloadFromGitHub(RepoName,Branch,FileAddress)
local function doRealDownload(url)
local hwtable=component.list("internet")
local found=false
for k,v in pairs(hwtable) do
@ -11,8 +12,8 @@ function DownloadFromGitHub(RepoName,Branch,FileAddress)
error("The downloader requires an Internet card.")
end
local url="https://raw.githubusercontent.com/" .. RepoName .. "/" .. Branch .. "/" .. FileAddress
local handle=component.internet.request(url)
local ans=""
while true do
local tmp=handle.read()
@ -24,6 +25,11 @@ function DownloadFromGitHub(RepoName,Branch,FileAddress)
return ans
end
function DownloadFromGitHub(RepoName,Branch,FileAddress)
local url="https://raw.githubusercontent.com/" .. RepoName .. "/" .. Branch .. "/" .. FileAddress
return doRealDownload(url)
end
function DownloadFromOCS(FileAddress)
return DownloadFromGitHub("Kiritow/OpenComputerScripts","master",FileAddress)
end
@ -44,7 +50,7 @@ function WriteStringToFile(StringValue,FileName,IsAppend)
return true,"Success"
end
-- From Downloader
----------------------------- End of From Downloader
local code_lst=
{

View File

@ -1,4 +1,13 @@
local component=require("component")
local serialization = require("serialization")
function serialize(value)
return serialization.serialize(value)
end
function unserialize(str)
return serialization.unserialize(str)
end
function getTableSize(t)
local cnt=0
@ -20,7 +29,7 @@ function proxy(componentType,beginWith)
local t=component.list(componentType)
local sz=getTableSize(t)
if(sz==0) then
print("Query List is Empty")
print("proxy: Query List is Empty")
return nil
elseif(sz==1) then
for k in pairs(t) do
@ -28,11 +37,11 @@ function proxy(componentType,beginWith)
end
else
if(beginWith == nil) then
print("beginWith value required.")
print("proxy: beginWith value required.")
return nil
end
if(type(beginWith) ~= "string") then
print("beginWith is not string")
print("proxy: beginWith is not string")
return nil
end
local bsz=string.len(beginWith)
@ -44,14 +53,14 @@ function proxy(componentType,beginWith)
traw=rawproxy(k)
cnt=1
else
print("Found more than 1 target.")
print("proxy: Found more than 1 target.")
return nil
end
end
end
if(cnt==0) then
print("Not found with beginWith value")
print("proxy: Not found with beginWith value")
return nil
else
return traw