def __init__(self, pbsNumber, user, downloadHeaderlist, outputDir, monitorInterval = UrlDownloaderMonitor.DEF_TIME_INTERVAL, pbsUrl = PBS_URL): self._pbsUrl = pbsUrl; self._pbsNumber = pbsNumber self._user = user self._downloadHeaderlist = downloadHeaderlist self._outputDir = outputDir self._downloader = UrlDownloader() self._downloaderMonitor = PbsDownloadMonitor(self._downloader, monitorInterval)
class PbsProductGetter: PBS_URL = 'http://suwon.qb.sec.samsung.net' def __init__(self, pbsNumber, user, downloadHeaderlist, outputDir, monitorInterval = UrlDownloaderMonitor.DEF_TIME_INTERVAL, pbsUrl = PBS_URL): self._pbsUrl = pbsUrl; self._pbsNumber = pbsNumber self._user = user self._downloadHeaderlist = downloadHeaderlist self._outputDir = outputDir self._downloader = UrlDownloader() self._downloaderMonitor = PbsDownloadMonitor(self._downloader, monitorInterval) def __isFileNeedToDownload(self, name): for header in self._downloadHeaderlist: if name.startswith(header): return True return False def getPbsUrl(self): return self._pbsUrl def _waitForBuilding(self, analyser, timeInterval): if analyser == None: return while analyser.getPercentage() >= 0: sys.stdout.write("\n-------------------------------\n") sys.stdout.write('building in progress: ' + str(analyser.getPercentage()) + '%\n') sys.stdout.write('\n-------------------------------\n') time.sleep(timeInterval) def _prepare(self): urlLoader = PbsUrlLoader(url = self.getPbsUrl(), user = self._user, pageId = self._pbsNumber) analyser = PbsProductsAnalyser(urlLoader) if analyser.analyse() == False: self._waitForBuilding(analyser, self._downloaderMonitor.getMonitoringInterval()) if self._outputDir == None: self._outputDir = '' else: self._outputDir += '/' products = analyser.getProducts() for p in products: if self.__isFileNeedToDownload(p.getFileName()): task = UrlDownloadTask(p, self._outputDir + p.getFileName()) self._downloader.append(task) def startDownloading(self): self._prepare() self._downloader.startDownload() if self._downloaderMonitor != None: self._downloaderMonitor.startMonitoring()