downloadkit/downloadkit.py
changeset 139 9baccbcc5509
parent 138 7b2d146ef884
child 140 55dd69d60bbc
equal deleted inserted replaced
138:7b2d146ef884 139:9baccbcc5509
   116 		self.status = self.unzip(self.filename, self.levels, self.deletelevels)
   116 		self.status = self.unzip(self.filename, self.levels, self.deletelevels)
   117 
   117 
   118 threadlist = []
   118 threadlist = []
   119 def schedule_unzip(filename, unziplevel, deletelevel):
   119 def schedule_unzip(filename, unziplevel, deletelevel):
   120 	global options
   120 	global options
       
   121 	if options.nounzip :
       
   122 		return
   121 	if options.dryrun :
   123 	if options.dryrun :
   122 		global unzip_list
   124 		global unzip_list
   123 		if unziplevel > 0:
   125 		if unziplevel > 0:
   124 			unzip_list.append("7z x -y %s" % filename)
   126 			unzip_list.append("7z x -y %s" % filename)
   125 			if unziplevel > 1:
   127 			if unziplevel > 1:
   135 	threadlist.append(unzipthread)
   137 	threadlist.append(unzipthread)
   136 	unzipthread.start()
   138 	unzipthread.start()
   137 
   139 
   138 def complete_outstanding_unzips():
   140 def complete_outstanding_unzips():
   139 	global options
   141 	global options
   140 	if options.dryrun:
   142 	if options.dryrun or options.nounzip:
   141 		return
   143 		return
   142 	print "Waiting for outstanding commands to finish..."
   144 	print "Waiting for outstanding commands to finish..."
   143 	for thread in threadlist:
   145 	for thread in threadlist:
   144 		thread.join()  
   146 		thread.join()  
   145 	
   147 	
   259 	# wait for the unzipping threads to complete
   261 	# wait for the unzipping threads to complete
   260 	complete_outstanding_unzips()  
   262 	complete_outstanding_unzips()  
   261 
   263 
   262 	return 1
   264 	return 1
   263 
   265 
   264 parser = OptionParser(usage="Usage: %prog [options] version", version="%prog 0.3")
   266 parser = OptionParser(usage="Usage: %prog [options] version", version="%prog 0.4")
   265 parser.add_option("-n", "--dryrun", action="store_true", dest="dryrun",
   267 parser.add_option("-n", "--dryrun", action="store_true", dest="dryrun",
   266 	help="print the files to be downloaded, the 7z commands, and the recommended deletions")
   268 	help="print the files to be downloaded, the 7z commands, and the recommended deletions")
   267 parser.add_option("--nosrc", action="store_true", dest="nosrc",
   269 parser.add_option("--nosrc", action="store_true", dest="nosrc",
   268 	help="Don't download any of the source code available directly from Mercurial")
   270 	help="Don't download any of the source code available directly from Mercurial")
   269 parser.set_defaults(dryrun=False, nosrc=False)
   271 parser.add_option("--nounzip", action="store_true", dest="nounzip",
       
   272 	help="Just download, don't unzip or delete any files")
       
   273 parser.set_defaults(dryrun=False, nosrc=False, nounzip=False)
   270 
   274 
   271 (options, args) = parser.parse_args()
   275 (options, args) = parser.parse_args()
   272 if len(args) != 1:
   276 if len(args) != 1:
   273 	parser.error("Must supply a PDK version, e.g. 3.0.e")
   277 	parser.error("Must supply a PDK version, e.g. 3.0.e")
   274 
   278