Started to add support for options to filter the versions to be downloaded

master
yorch 11 years ago
parent 031d423420
commit 3241398e80

@ -1,23 +1,57 @@
import urllib.request,re,getopt,os #! /usr/bin/env python3
url="http://builder.blender.org/download"
import urllib.request,re,getopt,os,sys
argsx = "--platform=linux --arch=x64 --branch=gooseberry -p=linux -a=x64 -b=gooseberry".split()
def get_links(**options):
ptn='(?<=href\=\")[^\"]*' try:
source=urllib.request.urlopen(url).read().decode("utf-8") print(sys.argv[1:])
links=(re.findall(ptn,source)) opts, args = getopt.getopt(argsx,"p:a:b:",["platform=","arch=","branch="])
masked_links = [] print(args)
for l in range(0,len(links)): print('it worked')
if links[l].find("blender") != -1: except getopt.GetoptError as err:
masked_links.append(links[l])
try: #print help information and exit:
opt = options.get() print(str(err)) # will print something like "option -a not recognized"
except TypeError: #usage()
opt = "none" print('it didn\'t worke')
return masked_links sys.exit(2)
links = get_links()
class BBBD():
for l in links: def __init__(self):
print(url+os.sep+l,'/Users/makinegx15/Desktop'+os.sep+l) self.url="http://builder.blender.org/download"
urllib.request.urlretrieve(url+os.sep+l,'/Users/makinegx15/Desktop'+os.sep+l) self.links = self.get_links()
print('downloaded :'+l)
def get_links(self):
ptn='(?<=href\=\")[^\"]*'
source=urllib.request.urlopen(self.url).read().decode("utf-8")
self.link=(re.findall(ptn,source))
masked_links = []
for l in range(0,len(self.link)):
if self.link[l].find("blender") != -1:
masked_links.append(self.link[l])
self.link = masked_links
return self.link
def get_masked_links(self,*ptn):
links = set(self.links)
masked_links = set(links)
for p in ptn:
for l in links:
if l.find(p) == -1:
if l in masked_links:
masked_links.remove(l)
return masked_links
bd = BBBD()
for i in bd.get_masked_links('win',"64.","gooseberry"):
print(bd.url+os.sep+i)
#~ for l in links:
#~ print(url+os.sep+l,'/Users/makinegx15/Desktop'+os.sep+l)
#~ urllib.request.urlretrieve(url+os.sep+l,'/Users/makinegx15/Desktop'+os.sep+l)
#~ print('downloaded :'+l)

Loading…
Cancel
Save