20 posts
Posted 18 December 2012 - 03:40 PM
So I am trying to download scripts I write on my mac and then push to GitHub onto my turtle so it can run it! I do this so I can use and external IDE. Here is what I know you can do
pastebin get ID Program Name
This will download a script from Pastebin at the id and put it onto the turtle with the "Program Name"
Any way I can do this with GitHub?
Google could not answer me and I tried a few different ways I could think of before coming to the forums to ask for help!
Thanks in advance!
-Birdgeek3
7508 posts
Location
Australia
Posted 18 December 2012 - 03:58 PM
yes there is. using the http api and sending a request and reading the RAW version on github…. It MUST be the RAW url that you provide…
EDIT: Easiest option, copy the pastebin source and just allow it to take any url
20 posts
Posted 19 December 2012 - 11:47 AM
yes there is. using the http api and sending a request and reading the RAW version on github…. It MUST be the RAW url that you provide…
EDIT: Easiest option, copy the pastebin source and just allow it to take any url
Any clue how to do this?
Here is the pastebin to what I got so far
http://pastebin.com/VFT2haHH
2088 posts
Location
South Africa
Posted 19 December 2012 - 11:56 AM
You just copied the pastebin code into pastebin, haha :P/> Search the programs thread, I saw a program for GitHub and another website.
Ill look for it now…
20 posts
Posted 19 December 2012 - 12:34 PM
You just copied the pastebin code into pastebin, haha :P/> Search the programs thread, I saw a program for GitHub and another website.
Ill look for it now…
Io changed the URL in the get function from pastebin to
http://www.raw.github/
1214 posts
Location
The Sammich Kingdom
Posted 19 December 2012 - 12:38 PM
Well Github's URL is in a few pieces:
https://raw.github.com/user/repo/branch/path
So just pull data from the URL based off of that format and save to a file.
20 posts
Posted 19 December 2012 - 01:02 PM
Update*
This is the separate program I have written, always prints Failed so something doesn't like me. I don't fully understand the http api so it's got to be something simple.
http://pastebin.com/9c5mAVJg
1214 posts
Location
The Sammich Kingdom
Posted 19 December 2012 - 01:11 PM
Here is something really simple:
local args = {...}
if #args ~= 5 then
error("Usage: "..shell.getRunningProgram().." <user> <repo> <branch> <path> <save file>")
end
local h = http.get("https://raw.github.com/"..args[1].."/"..args[2].."/"..args[3].."/"..args[4]).readAll()
if h then
if not fs.exists(args[5]) then
f = fs.open(args[5], "w")
f.write(h)
f.close()
print("File '"..args[5].."' downloaded.")
else
error("File '"..args[5].."' already exists.")
end
else
error("Could not download file!")
end
Note: This is untested but it SHOULD work.
20 posts
Posted 19 December 2012 - 01:18 PM
Here is something really simple:
local args = {...}
if #args ~= 5 then
error("Usage: "..shell.getRunningProgram().." <user> <repo> <branch> <path> <save file>")
end
local h = http.get("https://raw.github.com/"..args[1].."/"..args[2].."/"..args[3].."/"..args[4]).readAll()
if h then
if not fs.exists(args[5]) then
f = fs.open(args[5], "w")
f.write(h)
f.close()
print("File '"..args[5].."' downloaded.")
else
error("File '"..args[5].."' already exists.")
end
else
error("Could not download file!")
end
Note: This is untested but it SHOULD work.
This works wondefully! Thanks for helping my stupid self out.
Will try better next time
Thanks
-Bird
1214 posts
Location
The Sammich Kingdom
Posted 19 December 2012 - 01:29 PM
Here is something really simple:
local args = {...}
if #args ~= 5 then
error("Usage: "..shell.getRunningProgram().." <user> <repo> <branch> <path> <save file>")
end
local h = http.get("https://raw.github.com/"..args[1].."/"..args[2].."/"..args[3].."/"..args[4]).readAll()
if h then
if not fs.exists(args[5]) then
f = fs.open(args[5], "w")
f.write(h)
f.close()
print("File '"..args[5].."' downloaded.")
else
error("File '"..args[5].."' already exists.")
end
else
error("Could not download file!")
end
Note: This is untested but it SHOULD work.
This works wondefully! Thanks for helping my stupid self out.
Will try better next time
Thanks
-Bird
Just here to help.
8543 posts
Posted 19 December 2012 - 02:04 PM
Also, make sure you're using an up-to-date version. I believe it's pre-1.4 versions of ComputerCraft wherein the http API cannot connect to https:// addresses.