<s> """<STR_LIT>""" <EOL> import subprocess <EOL> from cvs2svn_lib . common import FatalError <EOL> from cvs2svn_lib . common import CommandError <EOL> from cvs2svn_lib . log import logger <EOL> def call_command ( command , ** kw ) : <EOL> """<STR_LIT>""" <EOL> logger . debug ( '<STR_LIT>' % ( command , ) ) <EOL> try : <EOL> retcode = subprocess . call ( command , ** kw ) <EOL> if retcode < <NUM_LIT:0> : <EOL> raise FatalError ( <EOL> '<STR_LIT>' <EOL> % ( - retcode , '<STR_LIT:U+0020>' . join ( command ) , ) <EOL> ) <EOL> elif retcode > <NUM_LIT:0> : <EOL> raise FatalError ( <EOL> '<STR_LIT>' <EOL> % ( retcode , '<STR_LIT:U+0020>' . join ( command ) , ) <EOL> ) <EOL> except OSError , e : <EOL> raise FatalError ( <EOL> '<STR_LIT>' <EOL> % ( e , '<STR_LIT:U+0020>' . join ( command ) , ) <EOL> ) <EOL> class CommandFailedException ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def check_command_runs ( command , commandname ) : <EOL> """<STR_LIT>""" <EOL> logger . debug ( '<STR_LIT>' % ( command , ) ) <EOL> try : <EOL> pipe = subprocess . Popen ( <EOL> command , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . PIPE , <EOL> ) <EOL> except OSError , e : <EOL> raise CommandFailedException ( '<STR_LIT>' % ( commandname , e , ) ) <EOL> ( stdout , stderr ) = pipe . communicate ( ) <EOL> if pipe . returncode or stderr : <EOL> msg = '<STR_LIT>' % ( commandname , pipe . returncode , ) <EOL> if stderr : <EOL> msg += '<STR_LIT>' % ( stderr , ) <EOL> raise CommandFailedException ( msg ) <EOL> def get_command_output ( command ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> logger . debug ( '<STR_LIT>' % ( command , ) ) <EOL> pipe = subprocess . Popen ( <EOL> command , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . PIPE , <EOL> ) <EOL> ( stdout , stderr ) = pipe . communicate ( ) <EOL> if pipe . returncode or stderr : <EOL> raise CommandError ( '<STR_LIT:U+0020>' . join ( command ) , pipe . returncode , stderr ) <EOL> return stdout </s>
