This script will download zip file, extract and install/run program that has silent options. You need to supply url, zip filename, setup app name, directory to save to, directory will be created if it doesn’t exist, and silent options. The downloaded file will be deleted on completion.
import urllib2, subprocess, os, sys, shutil
url = 'http://www.thewebsomewhere.com/yourapp.zip'
filename = 'yourapp.zip'
appfromzip = 'setup.exe'
filedirectory = "directory/to/save/to"
options1 = '-yourswitches1'
options2 = '/yourswitches2'
drive = os.path.splitdrive(sys.executable)[0] + os.sep
destDir = os.path.join(drive, filedirectory)
if not os.path.isdir(destDir):
os.makedirs(destDir)
Zipdownload = os.path.join(destDir, filename)
getfile = urllib2.urlopen(url)
with open(Zipdownload, 'wb') as savefile:
shutil.copyfileobj(getfile, savefile)
from zipfile import ZipFile
thefile=ZipFile(Zipdownload)
thefile.extractall(destDir)
thefile.close()
os.remove(Zipdownload)
installapplication = os.path.join(destDir, appfromzip)
process = subprocess.Popen([ installapplication, options1, options2 ],cwd=destDir,stdout=subprocess.PIPE)
for line in iter(process.stdout.readline,''):
print line.rstrip();