Jump to content




Auto Updater


  • You cannot reply to this topic
7 replies to this topic

#1 Astrophylite

  • Members
  • 121 posts
  • Locationgps.locate()

Posted 25 July 2015 - 01:57 PM

Hi,

So I have posted my Improved Turtle API but loads of people are complaining why I am not using Pastebin.
Then, someone said, why don't I just create an auto-updater? So I set to work but I am stuck at the thinking process.
Everyone I normally get help from is currently offline (at the time of posting) so I came here.
So, as you have probably gathered, my question is : how do I create an auto-updater for Pastebin?
I already have the version file uploaded to pastebin and the turtle API (not ready for download as of yet).

Any help will be appreciated,
ZiR

#2 ROBdk97

  • Members
  • 18 posts
  • LocationGermany

Posted 25 July 2015 - 02:07 PM

Maybe you also have a pastebin in which you increase a number every time you update your code and you let your program download it and if the number in this file is higher your program knows it should download your program again so it is a newer version.

Sorry for my English ;-)
ROB

#3 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 25 July 2015 - 02:07 PM

Don't. That would be my simple answer. If people want to update they will - and you can provide the utilities to do that. However checking and automatically fetching updates is pain in the neck for both developer and user - if a program takes several seconds to load because it needs to access a remote server then they'll just remove the update part.

I'm going to presume you have a pastebin account - that means you can preserve the same pastebin ID every time. Then you can fetch the paste every time you load the program, and if you cannot find it then just load a cached version. Alternatively you could have a separate paste containing the latest version number and, if it doesn't match the current version number, update.

local update = http.get("http://pastebin.com/raw.php?i=<version_paste_id>")
if update and update.readAll() ~= "<current_version>" then
  update.close()
  shell.run("pastebin get <paste_id> turtleAPI")
end

Edited by SquidDev, 03 August 2015 - 07:11 AM.


#4 Astrophylite

  • Members
  • 121 posts
  • Locationgps.locate()

Posted 25 July 2015 - 02:10 PM

Thank you both for your very quick responses.
I am going to go with SquidDev's response because it is something I do with all my programs, but evidently not this one ^_^

Again, thank you both for your responses.
ZiR

#5 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 25 July 2015 - 02:26 PM

View PostSquidDev, on 25 July 2015 - 02:07 PM, said:

  shell.execute("pastebin get <paste_id> turtleAPI")

You mean 'shell.run'?

#6 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 25 July 2015 - 02:28 PM

if fs.exists("/apis/turtle") then
  fs.delete("/apis/turtle")
end
shell.run("pastebin get w7DnM2Rt /apis/turtle")
os.loadAPI("/apis/turtle")
One thing I would do which I should have mentioned is not delete the file until you know you can get it:

local response = http and http.get("http://pastebin.com/raw.php?i=w7DnM2Rt")
if response then
  local handle = fs.open("turtleAPI", "w")
  handle.write(response.readAll())
  handle.close()
  response.close()
end


Otherwise if HTTP is disabled or pastebin is down, turtles aren't left disabled. :)

View PostHPWebcamAble, on 25 July 2015 - 02:26 PM, said:

You mean 'shell.run'?
That is what I wrote. Totally. (I was probably thinking os.execute() from vanilla Lua - sorry).

Edited by SquidDev, 25 July 2015 - 02:29 PM.


#7 Astrophylite

  • Members
  • 121 posts
  • Locationgps.locate()

Posted 25 July 2015 - 03:24 PM

View PostSquidDev, on 25 July 2015 - 02:28 PM, said:

if fs.exists("/apis/turtle") then
  fs.delete("/apis/turtle")
end
shell.run("pastebin get w7DnM2Rt /apis/turtle")
os.loadAPI("/apis/turtle")
One thing I would do which I should have mentioned is not delete the file until you know you can get it:

local response = http and http.get("http://pastebin.com/raw.php?i=w7DnM2Rt")
if response then
  local handle = fs.open("turtleAPI", "w")
  handle.write(response.readAll())
  handle.close()
  response.close()
end


Otherwise if HTTP is disabled or pastebin is down, turtles aren't left disabled. :)

View PostHPWebcamAble, on 25 July 2015 - 02:26 PM, said:

You mean 'shell.run'?
That is what I wrote. Totally. (I was probably thinking os.execute() from vanilla Lua - sorry).
I will change it now :D Thanks for reminding me!!

ZiR

EDIT: Changed the script to allow checking for errors ^_^. Thank you SquidDev :D

Edited by _zircon_, 25 July 2015 - 03:30 PM.


#8 jerimo

  • Members
  • 74 posts

Posted 25 July 2015 - 11:24 PM

I believe it had been already mentioned in passing in your API thread, but rather than try to put your a uff on pastebin and then make an installer it was suggested that you simply have the installer on pastebin install the installer you already use. The complaint was not that the API itself was nice t in pastebin, but rather that it was complex to install, compared to pastebin run code





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users