Revision: 27871
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 25, 2010 13:20 by Keef
Initial Code
#!/usr/bin/python
import urllib2
import re
import os
from datetime import date
download = True
scriptdir = os.getcwd()
nsisdir = "C:\Program Files\NSIS"
tempdir = os.tempnam()
os.mkdir(tempdir)
def getHomePath():
if os.name == "posix":
return os.getenv("HOME")
elif os.name == "nt":
import win32com.client
objShell = win32com.client.Dispatch("WScript.Shell")
return objShell.SpecialFolders("MyDocuments")
try:
os.mkdir(getHomePath() + "/av_updates")
except os.error:
print "**** Folder exists, continuing... ****"
os.chdir(getHomePath() + "/av_updates")
if download:
try:
page = urllib2.urlopen("http://free.avg.com/gb-en/download-update").read()
except urllib2.HTTPError, e:
print '**** The server couldn\'t fulfill the request.', e.code, '****'
except urllib2.URLError, e:
print '**** We failed to reach a server. ', e.reason, '****'
else:
url1 = re.search(r"(http://download.avgfree.com/softw/90free/update/[^\"]+)\"\s+class=\"clr\"\s*>Windows[^<]+<\/a></td><td[^>]+>All\snecessary\smodules", page).group(1)
url2 = re.search(r"(http://download\.avgfree\.com/softw/90free/update/[^\"]+)\"\s+class=\"clr\"\s*>IAVI", page).group(1)
if url1 is not None:
print os.system("wget -S -N " + url1)
else:
print '**** Failed to retrieve modules url. ****'
if url2 is not None:
print os.system("wget -S -N " + url2)
else:
print '**** Failed to retrieve database url. ****'
print os.system("wget -S -N http://www.superantispyware.com/downloads/SASDEFINITIONS.EXE")
print os.system("wget -S -N http://www.malwarebytes.org/mbam/database/mbam-rules.exe")
print os.system("wget -S -N http://www.spybotupdates.biz/updates/files/spybotsd_includes.exe")
# Prepare our update script.
with open(os.path.join(scriptdir, 'av_updates.nsi'), 'r') as f:
template = f.read()
today = date.today()
template = template.replace('{{date}}', today.isoformat())
template = template.replace('{{scriptdir}}', scriptdir)
template = template.replace('{{avg_update_1}}', re.search(r"/((\w|[-.])+)$", url1).group(1))
template = template.replace('{{avg_update_2}}', re.search(r"/((\w|[-.])+)$", url2).group(1))
# Build our script!
buildfile = os.path.join(tempdir, today.isoformat() + '.nsi')
with open(buildfile, 'w') as f:
f.write(template)
os.chdir(nsisdir)
cmd = 'makensis "' + buildfile + '"'
print '**** ' + cmd + ' ****'
os.system(cmd)
Initial URL
Initial Description
This is a rather nasty first attempt, while it works under Windows XP there is no real error checking.
Initial Title
AV Updates script
Initial Tags
Initial Language
Python