Created
March 29, 2017 11:13
-
-
Save LasseSkogland/5608e1aba5ab7d0d4ab39f98f0340466 to your computer and use it in GitHub Desktop.
x64dbg Updater
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import json | |
import time | |
import os | |
import subprocess | |
import shutil | |
from zipfile import ZipFile | |
DATE_FORMAT = '%Y-%m-%d_%H-%M' | |
ghData = json.loads(urllib2.urlopen( | |
'https://api.github.com/repos/x64dbg/x64dbg/releases/latest').read()) | |
latestFile = ghData['assets'][0]['name'] | |
latestDate = time.strptime(latestFile[9:-4], DATE_FORMAT) | |
downloadUrl = ghData['assets'][0]['browser_download_url'] | |
if os.path.isfile('version'): | |
with open('version', 'r') as versionFile: | |
installDate = time.strptime(versionFile.read(), DATE_FORMAT) | |
else: | |
installDate = time.localtime(0) | |
if latestDate > installDate: | |
print 'New version: ', time.strftime(DATE_FORMAT, latestDate) | |
if not os.path.exists(latestFile): | |
print 'Downloading...' | |
res = urllib2.urlopen(downloadUrl) | |
fileData = res.read() | |
with open(latestFile, 'wb') as f: | |
f.write(fileData) | |
print 'Extracting...' | |
with ZipFile(latestFile) as zip: | |
for file in zip.namelist(): | |
if file.startswith('release/'): | |
zip.extract(file) | |
print 'Installing...' | |
subprocess.call(['xcopy', '/S', '/Y', 'release\\*', '.']) | |
with open('version', 'w') as f: | |
f.write(time.strftime(DATE_FORMAT, latestDate)) | |
print 'Cleaning up...' | |
os.remove(latestFile) | |
shutil.rmtree('release') | |
print 'Done' | |
else: | |
print 'Already up to date' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment