summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/countdown.py
blob: 28352ff434c68ac36c8a04d54dc654b423cf4d25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

import sys
import time

from portage.output import colorize

def countdown(secs=5, doing="Starting"):
	if secs:
		print(">>> Waiting",secs,"seconds before starting...")
		print(">>> (Control-C to abort)...\n"+doing+" in: ", end=' ')
		ticks=range(secs)
		ticks.reverse()
		for sec in ticks:
			sys.stdout.write(colorize("UNMERGE_WARN", str(sec+1)+" "))
			sys.stdout.flush()
			time.sleep(1)
		print()