Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Check Pastebin for an update, update the executable if required#
- #Designed to be copied/pasted into code#
- #Import required modules
- import sys
- import urllib.request
- import logging
- #Declare Variables
- ##Current Code Version
- actualVersion = "003"
- ##ID for version checking
- versionID = "S73PQGEA"
- ##ID for downloading source
- sourceID = "VxMfuSY0"
- #Attempt to check if an updated version is available
- logging.debug("Checking for new version online")
- opener = urllib.request.FancyURLopener({})
- url = "http://pastebin.com/raw/"
- f = opener.open(url+versionID)
- content = f.read().decode("utf-8")
- logging.debug("Checked for new version")
- #Compare version numbers, download new source if required
- if content != actualVersion:
- logging.warn("A new version is available!")
- logging.warn("Attempting to install latest version")
- opener = urllib.request.FancyURLopener({})
- url = "http://pastebin.com/raw/"
- f = opener.open(url+sourceID)
- content = f.read()
- logging.debug("Downloaded new version")
- logging.debug("Attempting to overwrite file")
- f_h = open(str(sys.argv[0]), "wb")
- f_h.write(content)
- f_h.close()
- logging.warn("Installed latest version - Restart to see!")
- else:
- logging.debug("No new version found")
Add Comment
Please, Sign In to add comment