Created
June 18, 2012 16:52
-
-
Save billroy/2949377 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from optparse import OptionParser | |
parser = OptionParser() | |
parser.add_option("-n", "--number", | |
dest="count", type='int', | |
help="which potato am i") | |
parser.add_option("-x", "--exit", | |
dest="exit", type='int', | |
help="exit after this many logging cycles") | |
(options, args) = parser.parse_args() | |
potatocount = options.count or -1 | |
print potatocount, "potatoes starting" | |
import sys | |
sys.stdout.flush() | |
import time | |
while options.exit: | |
time.sleep(5) | |
print potatocount, "potatoes here" | |
sys.stdout.flush() | |
options.exit = options.exit - 1 | |
print potatocount, "potatoes finished" | |
sys.stdout.flush() | |
sys.exit(potatocount) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment