pct_place = (len(self.prog_bar) / 2) - len(str(percent_done)) pct_string = '%d%%' % percent_done self.prog_bar = self.prog_bar[0:pct_place] + \ (pct_string + self.prog_bar[pct_place + len(pct_string):]) def __str__(self): return str(self.prog_bar) if __name__ == '__main__': # print a dynamic updating progress bar on one line: # # [################100%##################] 10s/10s # done p = Popen(['setsid','python','/home/pi/backup/ka-lite/kalite/manage.py','kaserve','host=0.0.0.0','port=7007','threads=10','daemonize=false', 'pidfile="/home/pi/backup/ka-lite/kalite/runcherrypiserver.pid"']) secs = 60 p = ProgressBar(secs) print 'Khan Academy is also available for free at www.khanacademy.org (hope you have fast internet).' print '.' print "Please wait while Khan Academy is starting up: that's 3500 videos totalling more than 50 GB..." # spawn asych (threads/processes/etc) code here that runs for secs. # the call to .animate() blocks the main thread. p.animate() print 'KA-Lite is ready to go!' call(["kweb","-J","http://127.0.0.1:7007"])