downloadkit/downloadkit.py
changeset 171 5f1dcce7f6d4
parent 170 dd0383270574
child 174 5ebd70511e4c
equal deleted inserted replaced
170:dd0383270574 171:5f1dcce7f6d4
    23 from BeautifulSoup import BeautifulSoup
    23 from BeautifulSoup import BeautifulSoup
    24 from optparse import OptionParser
    24 from optparse import OptionParser
    25 import hashlib
    25 import hashlib
    26 import xml.etree.ElementTree as ET 
    26 import xml.etree.ElementTree as ET 
    27 
    27 
    28 user_agent = 'downloadkit.py script'
    28 version = '0.10'
       
    29 user_agent = 'downloadkit.py script v' + version
    29 headers = { 'User-Agent' : user_agent }
    30 headers = { 'User-Agent' : user_agent }
    30 top_level_url = "http://developer.symbian.org"
    31 top_level_url = "http://developer.symbian.org"
    31 download_list = []
    32 download_list = []
    32 unzip_list = []
    33 unzip_list = []
    33 
    34 
   358 		downloadurl = urlbase + result['href']
   359 		downloadurl = urlbase + result['href']
   359 		filename = result['title']
   360 		filename = result['title']
   360 
   361 
   361 		if options.nosrc and re.match(r"(src_sfl|src_oss)", filename) :
   362 		if options.nosrc and re.match(r"(src_sfl|src_oss)", filename) :
   362 			continue 	# no snapshots of Mercurial source thanks...
   363 			continue 	# no snapshots of Mercurial source thanks...
       
   364 		if options.nowinscw and re.search(r"winscw", filename) :
       
   365 			continue 	# no winscw emulator...
   363 
   366 
   364 		if download_file(filename, downloadurl) != True :
   367 		if download_file(filename, downloadurl) != True :
   365 			continue # download failed
   368 			continue # download failed
   366 
   369 
   367 		# unzip the file (if desired)
   370 		# unzip the file (if desired)
   380 	# wait for the unzipping threads to complete
   383 	# wait for the unzipping threads to complete
   381 	complete_outstanding_unzips()  
   384 	complete_outstanding_unzips()  
   382 
   385 
   383 	return 1
   386 	return 1
   384 
   387 
   385 parser = OptionParser(version="%prog 0.9", usage="Usage: %prog [options] version")
   388 parser = OptionParser(version="%prog "+version, usage="Usage: %prog [options] version")
   386 parser.add_option("-n", "--dryrun", action="store_true", dest="dryrun",
   389 parser.add_option("-n", "--dryrun", action="store_true", dest="dryrun",
   387 	help="print the files to be downloaded, the 7z commands, and the recommended deletions")
   390 	help="print the files to be downloaded, the 7z commands, and the recommended deletions")
   388 parser.add_option("--nosrc", action="store_true", dest="nosrc",
   391 parser.add_option("--nosrc", action="store_true", dest="nosrc",
   389 	help="Don't download any of the source code available directly from Mercurial")
   392 	help="Don't download any of the source code available directly from Mercurial")
       
   393 parser.add_option("--nowinscw", action="store_true", dest="nowinscw",
       
   394 	help="Don't download the winscw emulator")
   390 parser.add_option("--nounzip", action="store_true", dest="nounzip",
   395 parser.add_option("--nounzip", action="store_true", dest="nounzip",
   391 	help="Just download, don't unzip or delete any files")
   396 	help="Just download, don't unzip or delete any files")
   392 parser.add_option("--nodelete", action="store_true", dest="nodelete",
   397 parser.add_option("--nodelete", action="store_true", dest="nodelete",
   393 	help="Do not delete files after unzipping")
   398 	help="Do not delete files after unzipping")
   394 parser.add_option("--progress", action="store_true", dest="progress",
   399 parser.add_option("--progress", action="store_true", dest="progress",
   400 parser.add_option("--debug", action="store_true", dest="debug", 
   405 parser.add_option("--debug", action="store_true", dest="debug", 
   401 	help="debug HTML traffic (not recommended!)")
   406 	help="debug HTML traffic (not recommended!)")
   402 parser.set_defaults(
   407 parser.set_defaults(
   403 	dryrun=False, 
   408 	dryrun=False, 
   404 	nosrc=False, 
   409 	nosrc=False, 
       
   410 	nowinscw=False, 
   405 	nounzip=False, 
   411 	nounzip=False, 
   406 	nodelete=False, 
   412 	nodelete=False, 
   407 	progress=False,
   413 	progress=False,
   408 	username='',
   414 	username='',
   409 	password='',
   415 	password='',