本文整理汇总了Python中ProgressBar.ProgressBar.update方法的典型用法代码示例。如果您正苦于以下问题:Python ProgressBar.update方法的具体用法?Python ProgressBar.update怎么用?Python ProgressBar.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressBar.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: processFiles
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import update [as 别名]
def processFiles(self, files, folderPath):
"""function processFiles
returns []
"""
if _logger.getEffectiveLevel() == 30:
import os
sumSize = 0
for file in files:
sumSize += os.path.getsize(folderPath+file)
bar = ProgressBar(sumSize)
else:
bar = False
#Creating MULTI FASTA file, with all genens
import os
fastaFile = open(os.path.expanduser("~/Documents/th6_MaartenJoost_multi.fasta"), 'w')
# evt [http://docs.python.org/2/library/multiprocessing.html]
for file in sorted(files):
self.chromosomeNumber += 1
chromosome = Chromosome(file, folderPath, _DB, _logger, fastaFile)
self.oligosNumber += chromosome.oligosNumber
self.genesNumber += chromosome.genesNum
del(chromosome)
if bar: bar.update(os.path.getsize(folderPath+file))
if bar: del(bar)
示例2: __init__
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import update [as 别名]
class progressBar:
def __init__(self, title, indeterminate=False, gui=False):
self.indeterminate = indeterminate
osxgui = False
self.bar = None
if sys.platform == 'darwin':
osxgui = gui
if osxgui:
try:
self.bar = ProgressBar(title=title, indeterminate=indeterminate)
except:
pass
# oh well, no CocoaDialog probably
self.reset(title, indeterminate=indeterminate)
self.update('', 0) # Build progress bar string
def reset(self, title, indeterminate=False):
if indeterminate != self.indeterminate:
if self.bar: self.bar.finish()
self.indeterminate = indeterminate
if self.bar:
self.bar = ProgressBar(title=title, indeterminate=indeterminate)
self.progBar = "[]" # This holds the progress bar string
self.width = 40
self.amount = 0 # When amount == max, we are 100% done
def finish(self):
if self.bar: self.bar.finish()
def update(self, message='', fraction=0.0, after_args=()):
self.message = message
# Figure out how many hash bars the percentage should be
allFull = self.width - 2
percentDone = int(round(fraction*100))
numHashes = int(round(fraction * allFull))
# build a progress bar with hashes and spaces
self.progBar = "[" + '#'*numHashes + ' '*(allFull-numHashes) + "]"
# figure out where to put the percentage, roughly centered
percentPlace = (len(self.progBar) / 2) - len(str(percentDone))
percentString = ' '+ str(percentDone) + r"% "
# slice the percentage into the bar
self.progBar = self.progBar[0:percentPlace] + percentString + \
self.progBar[percentPlace+len(percentString):]
if self.bar: self.bar.update(percentDone, message)
if self.indeterminate:
sys.stdout.write(self.message + ' '.join(after_args) + '\r')
else:
sys.stdout.write(self.message + str(self.progBar) + ' '.join(after_args) + '\r')
sys.stdout.flush()
def __str__(self):
return str(self.progBar)
示例3: perfromSubmission
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import update [as 别名]
def perfromSubmission(self,matched,task):
njs=0
### Progress Bar indicator, deactivate for debug
if common.debugLevel == 0 :
term = TerminalController()
if len(matched)>0:
common.logger.info(str(len(matched))+" blocks of jobs will be submitted")
common.logger.debug("Delegating proxy ")
try:
common.scheduler.delegateProxy()
except CrabException:
common.logger.debug("Proxy delegation failed ")
for ii in matched:
common.logger.debug('Submitting jobs '+str(self.sub_jobs[ii]))
# fix arguments for unique naming of the output
common._db.updateResubAttribs(self.sub_jobs[ii])
try:
common.scheduler.submit(self.sub_jobs[ii],task)
except CrabException:
common.logger.debug('common.scheduler.submit exception. Job(s) possibly not submitted')
raise CrabException("Job not submitted")
if common.debugLevel == 0 :
try: pbar = ProgressBar(term, 'Submitting '+str(len(self.sub_jobs[ii]))+' jobs')
except: pbar = None
if common.debugLevel == 0:
if pbar :
pbar.update(float(ii+1)/float(len(self.sub_jobs)),'please wait')
### check the if the submission succeded Maybe not needed or at least simplified
sched_Id = common._db.queryRunJob('schedulerId', self.sub_jobs[ii])
listId=[]
run_jobToSave = {'status' :'S'}
listRunField = []
for j in range(len(self.sub_jobs[ii])):
if str(sched_Id[j]) != '':
listId.append(self.sub_jobs[ii][j])
listRunField.append(run_jobToSave)
common.logger.debug("Submitted job # "+ str(self.sub_jobs[ii][j]))
njs += 1
common._db.updateRunJob_(listId, listRunField)
self.stateChange(listId,"SubSuccess")
self.SendMLpost(self.sub_jobs[ii])
else:
common.logger.info("The whole task doesn't found compatible site ")
return njs
示例4: write_heuristics_data
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import update [as 别名]
def write_heuristics_data(start, n, res_fname, states_fname='data/states.txt', search=a_star, h_name='linear_conflict', heuristic=NPuzzle.linear_conflict):
"""
Write a file with information on states, depths, expanded nodes, and
running time for the 3 heuristics implemented on a specific search method.
"""
from ProgressBar import ProgressBar
import time
import re
with open(res_fname, 'a') as res_f, open(states_fname, 'r') as s_f:
K = 3
goal = NPuzzle(K, range(K*K))
for i in range(start):
s_f.readline()
print 'Reading states from file {:s}'.format(states_fname)
print 'Writing {} states data to file {:s}'.format(n, res_fname)
pb = ProgressBar() # a simple pogressbar
pb.start()
f_format = '{};{};{};{}\n'
if start == 0:
columns = ['state', 'steps', h_name + '_nodes', h_name + '_time']
res_f.write(f_format.format(*columns))
for i in range(n - start):
state_str = s_f.readline().strip()
state = [int (b) for b in re.findall('[0-9]+', state_str)]
initial = NPuzzle(3, state)
percent = float(i+start)/(n)
pb.update(percent)
try:
init_time1 = time.time()
n1, s1, path1 = search(initial, goal, heuristic)
end_time1 = time.time()
t1 = end_time1 - init_time1
except KeyboardInterrupt:
break
except:
t1 = 'NaN'
n1 = 'NaN'
s1 = 'NaN'
res_f.write(f_format.format(initial, s1, n1, t1))
res_f.flush()
pb.finish()
示例5: range
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import update [as 别名]
laserTimer += 1
if laserTimer > 500 and laserCounter != 0:
laserCounter -= 1
laserTimer = 0
ScoreTimer += 1
if ScoreTimer > 50:
Score += 1
ScoreTimer = 0
#draw lives and other player information bars
for life in range(0, player.lives):
windowSurface.blit(livesImage, [livesImage.get_height()*life, WINDOWHEIGHT - livesImage.get_height()])
laserBar.update((30 - laserCounter)/30)
laserBar.draw(windowSurface)
shieldBar.update((player.shield.timeLimit - player.timer)/player.shield.timeLimit)
shieldBar.draw(windowSurface)
healthBar.update(player.lives / 3)
healthBar.draw(windowSurface)
head = pygame.font.Font(None, 20)
text = head.render("Score: " + str(Score), True, [255,255,255])
windowSurface.blit(text, [30, 50])
# draw the window onto the screen
pygame.display.update()
mainClock.tick(40)
示例6: main
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import update [as 别名]
def main():
# Comprobación de errores de entrada #
if len(sys.argv) < 3:
uso()
mode = sys.argv[1]
ifile = sys.argv[2]
if mode not in ['-e', '-d'] or not os.path.exists(ifile):
uso()
try:
with open(ifile, 'rb') as f:
inf = f.read()
except:
print ("Error leyendo el archivo de entrada.")
sys.exit()
Nb = 4
Nk = 4
Nr = 10
if len(sys.argv) > 3 and sys.argv[3] == '-192':
Nk = 6
Nr = 12
elif len(sys.argv) > 3 and sys.argv[3] == '-256':
Nk = 8
Nr = 14
######################################
#key = getpass("Introduzca una contraseña de cifrado de {0} cifras hexadecimales: ".format(Nb * Nk * 2))
key = raw_input("Introduzca una contraseña de cifrado de {0} cifras hexadecimales: ".format(Nb * Nk * 2))
if len(key) < Nb * Nk * 2:
print ("Contraseña demasiado corta. Rellenando con \'0\' hasta alcanzar una longitud de {0} cifras.".format(Nb * Nk * 2))
key += "0"* (Nb * Nk * 2 - len(key))
elif len(key) > Nb * Nk * 2:
print ("Contraseña demasiado larga. Conservando únicamente las primeras {0} cifras.".format(Nb * Nk * 2))
key = key[:Nb * Nk * 2]
key = process_key(key, Nk)
expanded_key = expand_key(key, Nb, Nk, Nr)
if mode == '-e':
ofile = ifile + '.aes'
elif mode == '-d' and ifile.endswith('.aes'):
ofile = ifile[:-4]
if os.path.exists(ofile):
spam = raw_input('El archivo "{0}" ya existe. ¿Sobreescribir? [s/N]'.format(ofile))
if spam.upper() != 'S':
ofile = raw_input('Introduzca nuevo nombre de archivo: ')
else:
ofile = ifile
pb = ProgressBar(len(inf), 0)
output = None
if mode == '-e': # Encript
inf = padding(inf, Nb)
while inf:
block, inf = get_block(inf, Nb)
c = pb.update(len(inf))
if c: pb.show()
if mode == '-e': # Encript
block = Cipher(block, expanded_key, Nb, Nk, Nr)
elif mode == '-d': # Decript
block = InvCipher(block, expanded_key, Nb, Nk, Nr)
block = prepare_block(block)
if output: output += block
else: output = block
if mode == '-d': # Decript
output = unpadding(output, Nb)
with open(ofile, 'wb') as f:
#for block in output: f.write(block)
f.write(output)
print('')
sys.exit()
示例7: len
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import update [as 别名]
#Update StatusBar
supportBar.increase()
size = len(str(supportBar.get()))
spaces = ' ' * (4 - size)
sys.stdout.write("{0}){1}\b\b\b\b\b".format(supportBar.get(), spaces))
sys.stdout.flush()
except KeyboardInterrupt:
print "\nProgram Closed Successfully!"
sys.exit(1)
except Exception,e:
print "\nException occurred!" + filename
print str(e)
supportBar.init()
progressBar.update()
#Write to Debug File
finalResults = ExportResults(aggr)
debug.write(filename + "\nDone.\n")
debug.flush()
for group in finalResults:
debug.write("---------------------------------------------------------\n")
for link in group:
debug.write(link + "\n")
debug.write("---------------------------------------------------------\n")
debug.flush()
finalResults = list(reversed(sorted(ExportResults(aggr), key=len)))
for group in finalResults:
示例8:
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import update [as 别名]
jobs_done = 0
if show_progress:
progress_bar.draw()
while jobs_done < nb_jobs:
cmd_and_output = results_queue.get()
jobs_done += 1
# FBR: more code factorization possible here
# if there is a default post_proc function which
# is the identity function
if output_to_file:
if has_post_proc_option:
output_file.write(post_proc_fun(cmd_and_output))
else:
output_file.write(cmd_and_output)
if show_progress:
progress_bar.update(jobs_done)
progress_bar.draw()
elif not output_to_file:
if has_post_proc_option:
sys.stdout.write(post_proc_fun(cmd_and_output))
else:
sys.stdout.write(cmd_and_output)
# cleanup
pyro_daemon_loop_cond = False
commands_file.close()
if output_to_file:
output_file.close()
# wait for everybody
for l in locks:
l.acquire()
# stop pyro server-side stuff
示例9: main
# 需要导入模块: from ProgressBar import ProgressBar [as 别名]
# 或者: from ProgressBar.ProgressBar import update [as 别名]
def main():
if len(sys.argv) > 1 and sys.argv[1] == "-demo":
demo()
if len(sys.argv) < 3:
help()
mode = sys.argv[1]
ifile = sys.argv[2]
if mode not in ["-e", "-d"] or not os.path.exists(ifile):
help()
try:
with open(ifile, "rb") as f:
inf = f.read()
except:
print("Error while trying to read input file.")
sys.exit()
Nb = 4
Nk = 4
Nr = 10
eggs = "".join(sys.argv[3:])
spam = eggs.find("-c")
if spam > -1 and eggs[spam + 2 : spam + 5] in ["128", "192", "256"]:
Nk = int(eggs[spam + 2 : spam + 5]) // 32
Nr = Nk + 6
key = raw_input("Enter a key, formed by {0} hexadecimal digits: ".format(Nk * 8))
key = key.replace(" ", "")
if len(key) < Nk * 8:
print("Key too short. Filling with '0'," "so the length is exactly {0} digits.".format(Nk * 8))
key += "0" * (Nk * 8 - len(key))
elif len(key) > Nk * 8:
print("Key too long. Keeping only the first {0} digits.".format(Nk * 8))
key = key[: Nk * 8]
key = process_key(key, Nk)
expanded_key = KeyExpansion(key, Nb, Nk, Nr)
if mode == "-e":
ofile = ifile + ".aes"
elif mode == "-d" and (ifile.endswith(".aes") or ifile.endswith(".cif")):
ofile = ifile[:-4]
else:
ofile = raw_input("Enter the output filename: ")
path_end = ifile.rfind("/")
if path_end == -1:
path_end = ifile.rfind("\\")
if path_end != -1:
ofile = ifile[: path_end + 1] + ofile
if os.path.exists(ofile):
spam = raw_input('The file "{0}" already exists. Overwrite? [y/N] '.format(ofile))
if spam.upper() != "Y":
ofile = raw_input("Enter new filename: ")
pb = ProgressBar(len(inf), 0)
output = None
if mode == "-e": # Encrypt
inf = padding(inf, Nb)
print("")
while inf:
block, inf = get_block(inf, Nb)
c = pb.update(len(inf))
if c:
pb.show()
if mode == "-e": # Encrypt
block = Cipher(block, expanded_key, Nb, Nk, Nr)
elif mode == "-d": # Decript
block = InvCipher(block, expanded_key, Nb, Nk, Nr)
block = prepare_block(block)
if output:
output += block
else:
output = block
if mode == "-d": # Decript
output = unpadding(output, Nb)
with open(ofile, "wb") as f:
f.write(output)
print("")
sys.exit()