<s> """<STR_LIT>""" <EOL> import os <EOL> class DirectoryExists ( OSError ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class DirectoryDoesntExist ( OSError ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class CommandFailed ( OSError ) : <EOL> pass <EOL> def sh ( command , null = True , prompt = False ) : <EOL> """<STR_LIT>""" <EOL> print "<STR_LIT>" , command <EOL> if prompt : <EOL> if raw_input ( "<STR_LIT>" ) . startswith ( '<STR_LIT:n>' ) : <EOL> return <EOL> if null : <EOL> command = "<STR_LIT>" % command <EOL> if os . system ( command ) != <NUM_LIT:0> : <EOL> raise CommandFailed ( command ) <EOL> def runChdirSafe ( f , * args , ** kw ) : <EOL> origdir = os . path . abspath ( '<STR_LIT:.>' ) <EOL> try : <EOL> return f ( * args , ** kw ) <EOL> finally : <EOL> os . chdir ( origdir ) </s>
