I must be missing a step

New to Github. While making changes and commiting those changes appears to be working, when I use my update script to get the changes to my linux box it shows the download but the changes that I committed are not there. In my update script I remove the old file first. Am I missing something ?
Thanks

I’m afraid that’s impossible to answer without knowing exactly what your update script looks like and what (if any) error messages you get.

That said, if your update script uses git pull or similar deleting the file first will break things, because it creates a conflict between local changes (file deleted) and upstream changes (file modified).

Here is my update script. I thought I could just remove the script and DL the new one without bothering with changes.

import os
clear = os.system("clear")
os.remove("Tools.py")
tools = os.system('wget https://raw.githubusercontent.com/cqsimple/tech/main/Tools.py')
os.remove("initial.py")
tools = os.system('wget https://raw.githubusercontent.com/cqsimple/tech/main/initial.py')
print("You should have the latest version now.")

In principle that should work, yes. I’m seeing a couple of issues with the update script:

  • The downloaded scripts aren’t marked as executable after being downloaded. I suspect this is the problem if you can’t call the scripts after updates. See os.chmod() to change that, or Path.chmod() for the nicer pathlib interface.
  • There’s no error checking on the downloads, the exit code provided by os.system() is ignored. If one of the downloads fails the script will still complete with a zero (“success”) exit code.
  • I highly recommend doing the downloads in Python instead of calling wget. The standard library has urllib.request, for a more convenient API check out requests (extra package). That also makes error checking easier.
  • I’d overwrite the previous version of the scripts only after successful download of the new ones. That way if a download fails the user still has access to the old (hopefully still working) version.
1 Like

Thanks Airtower-luna,

The DL scripts are executable so far, I will use the os.chmod to make sure from now on. I’ll look into the urllib.request. So far there hasn’t been any errors in the download but I see what you mean. I am assuming the the urllib will provide an exit code if the DL is ok or not.

Still doesn’t explain why a change in the code in github doesn’t show up in the downloaded file tho. Is there a time lag of some sort?

1 Like

Maybe? I wouldn’t be surprised if there’s some sort of caching between the repository data and the HTTPS download, but I don’t know Github’s internal systems. If you get the newer version after a little while that’s probably it.

I am beginning to think that is what is going on. Once I finally get all this to work the way I want hopefully updating not be so frequent.

I had to use urllib2 (old version of python) but it is working, thanks

1 Like