def exec_axel(conduit, remote, local, size, conn=None, text=None): """ Run axel binary to download""" if not size or size == -1: # we need size here. if not, we do nothing conduit.info(3, "axel got unknown size") return False # new thread to run axel conf = conduit.getConf() axel_debug = False if conf.debuglevel >= 3: axel_debug = True axel = Axel(debug=axel_debug, remote=remote, local=local, conn=conn) axel.start() # make axel outout look like yum output tm = TextMeter() size = int(size) filename = os.path.basename(local) if not text: text = filename # compose text console output tm.start(filename=filename, size=size, text=str(text)) #axel.start() lastSize = curSize = 0 slow_count = 0 while True: live = axel.isAlive() if curSize >= size or not live: if live: conduit.info(3, "axel is unexpectedly still alive") break try: curSize = os.path.getsize(local) except OSError, e: # maybe axel still don't generate local file # just continue to the following time call curSize = 0 pass # update the text bar every one second tm.update(curSize) time.sleep(0.5) # too slow, Less than 1000 bytes/sec transferred # the last 30 second if (curSize - lastSize) < 1000: slow_count += 1 if slow_count == 60: conduit.info( 3, "Operation too slow. Less than 1000 \ bytes/sec transferred the last 30 seconds") axel.stop() break lastSize = curSize
def exec_axel(conduit, remote, local, size, conn=None, text=None): """ Run axel binary to download""" if not size or size == -1: # we need size here. if not, we do nothing conduit.info(3, "axel got unknown size") return False # new thread to run axel conf = conduit.getConf() axel_debug = False if conf.debuglevel >= 3: axel_debug = True axel = Axel(debug=axel_debug, remote=remote, local=local, conn=conn) axel.start() # make axel outout look like yum output tm = TextMeter() size = int(size) filename = os.path.basename(local) if not text: text = filename # compose text console output tm.start(filename=filename, size=size, text=str(text)) #axel.start() lastSize = curSize = 0 slow_count = 0 while True: live = axel.isAlive() if curSize >= size or not live: if live: conduit.info(3, "axel is unexpectedly still alive") break try: curSize = os.path.getsize(local) except OSError, e: # maybe axel still don't generate local file # just continue to the following time call curSize = 0 pass # update the text bar every one second tm.update(curSize) time.sleep(0.5) # too slow, Less than 1000 bytes/sec transferred # the last 30 second if (curSize - lastSize) < 1000: slow_count += 1 if slow_count == 60: conduit.info(3, "Operation too slow. Less than 1000 \ bytes/sec transferred the last 30 seconds") axel.stop() break lastSize = curSize
ret = subprocess.call(['axel', '-q', DATA, '-o', FILENAME]) return ret def get_size(filename): return os.path.getsize(os.path.join(PWD, filename)) # MAIN a = Axel() a.start() time.sleep(2) # start tm = TextMeter() tm.start(filename=FILENAME, text=FILENAME) cur = get_size(FILENAME) while True: if cur >= SIZE: print "Done" break cur = get_size(FILENAME) print "size: %d" % cur tm.update(cur) time.sleep(1) tm.end(SIZE) a.join()
download.localpath = local # Hack: to set the localpath we want. try: checkfunc = (self.verifyPkg, (download, 1), {}) path = repo.getPackage(download, checkfunc=checkfunc) except IOError, e: self.logger.error("Cannot write to file %s. Error was: %s" % (local, e)) exit_code = 2 continue except RepoError, e: self.logger.error("Could not download/verify pkg %s: %s" % (download, e)) exit_code = 2 continue if not os.path.exists(local) or not os.path.samefile(path, local): progress = TextMeter() progress.start(basename=os.path.basename(local), size=os.stat(path).st_size) shutil.copy2(path, local) progress.end(progress.size) return exit_code def _groupPackages(self,pkglist): pkgGroups = {} for po in pkglist: na = '%s.%s' % (po.name,po.arch) if not na in pkgGroups: pkgGroups[na] = [po] else: pkgGroups[na].append(po) return pkgGroups # sligly modified from the one in YumUtilBase
ret = subprocess.call(['axel', '-q', DATA, '-o', FILENAME ]) return ret def get_size(filename): return os.path.getsize(os.path.join(PWD,filename)) # MAIN a = Axel() a.start() time.sleep(2) # start tm = TextMeter() tm.start(filename=FILENAME, text=FILENAME) cur = get_size(FILENAME) while True: if cur >= SIZE: print "Done" break cur = get_size(FILENAME) print "size: %d" %cur tm.update(cur) time.sleep(1) tm.end(SIZE) a.join()
ret = subprocess.call(['axel', '-q', DATA, '-o', FILENAME ]) return ret def get_size(filename): return os.path.getsize(os.path.join(PWD,filename)) # MAIN a = Axel() a.start() time.sleep(2) # start tm = TextMeter() tm.start(filename=FILENAME, size=SIZE, text=FILENAME) cur = get_size(FILENAME) while True: if cur >= SIZE: print "Done" break cur = get_size(FILENAME) print "size: %d" %cur tm.update(cur) time.sleep(1) tm.end(SIZE) a.join()