Jump to content




What am I doing wrong here?


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

#1 Sir_Mr_Bman

  • Members
  • 62 posts

Posted 25 April 2014 - 02:07 PM

So, I've made an installer that pulls files from my github.

What am I doing wrong here? It's not working, regardless of what I try.

-- GitGET Function
--
-- Written for Sir_Mr_Bmans GitHub
local function gitGet(file, save)
if fs.exists("/dwnlds") then
  fs.delete("/dwnlds")
end
fs.makeDir("/dwnlds")
term.setTextColor(colors.purple)
print("[GitGET] Getting file: "..file)
local response = http.get(
  "https://raw.githubusercontent.com/Sir-Mr-Bman/IndustrialSecurity/master/src/"..textutils.urlEncode(file)..".lua"	
)
if response then
  print("[GitGET] Server responded. Downloading...")
  local save = response.readAll()
  response.close()
  local h = fs.open("/dwnlds/"..save, "w")
  h.write(save)
  h.close()
  print("[GitGET] File downloaded.")
else
  print("[GitGET] Server did not respond. Is it offline?")
  print("[GitGET] Check your internet connection, and firewall settings.")
end
end

Any help is welcomed.

EDIT: Updated code.
EDIT: Fixed code spacing.

Edited by Sir_Mr_Bman, 25 April 2014 - 02:16 PM.


#2 viluon

  • Members
  • 183 posts
  • LocationCzech Republic

Posted 25 April 2014 - 02:22 PM

What kind of error are you getting? Is this all the code? I don't see any function call (gitGet(sth,sth))

Edited by viluon, 25 April 2014 - 02:29 PM.


#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 25 April 2014 - 02:23 PM

What does it do that indicates "not working" to you? What does the script print out? Does it throw any errors?

#4 Sir_Mr_Bman

  • Members
  • 62 posts

Posted 25 April 2014 - 02:32 PM

It doesn't throw any errors, it just doesn't download as it should. Also, I've only included the FUNCTION, not the entire program.

Thanks for the quick responses!

#5 viluon

  • Members
  • 183 posts
  • LocationCzech Republic

Posted 25 April 2014 - 02:41 PM

Eh, fine.. Then please post the entire program so we can see what's wrong there.. Moreover, you haven't answered my question: what's the error? or output? what changes in the filesystem can you see? what CC version are you using? is it 1.63? Did you whitelist github in your ComputerCraft.cfg? Please be specific.

"it just doesn't download as it should" That's not how an error report should look like.

1) What is 'should' here? What do you want your program to do?
2) What does it mean "it just doesn't download"? Does it mean the download isn't even started? did you try catching http_failure or http_success events?
3) What output can you see on the screen? Does the program write something? If yes, at which stage does it stop?

Edited by viluon, 25 April 2014 - 02:47 PM.


#6 Sir_Mr_Bman

  • Members
  • 62 posts

Posted 25 April 2014 - 06:45 PM

Sorry.
Here is a link to my entire program:

http://pastebin.com/ikFxj3Av

What happens is this:

When you run the program, it makes the first call to the "gitGet" method. This works as it should, at first.
The logger then says that it is attempting to connect to github.
The logger then replies and says that there was no response from github, and it attempts to go and try the next file.
The filesystem has not changed at all, other than creating the "dwnlds" file.

#7 viluon

  • Members
  • 183 posts
  • LocationCzech Republic

Posted 25 April 2014 - 06:49 PM

And there's nothing inside that file? (Looking at your code)

Edit:oh sorry its a directory I see

What version of CC do you use? (I'm on an Android device, cannot try the code now)

Edit2:don't be sorry, it's totally okay, just remember this next time ;)

Edited by viluon, 25 April 2014 - 06:53 PM.


#8 Sir_Mr_Bman

  • Members
  • 62 posts

Posted 26 April 2014 - 05:28 PM

It wasn't working for me at all... Humph.

#9 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 26 April 2014 - 05:33 PM

Are you on CC 1.63? Have you tried having it print out the final url it is using? Have you gone to that url in your browser to verify that it works?





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users