--- virt-cluster/vc/vcutil.py 2012/08/27 11:46:35 1 +++ virt-cluster/vc/vcutil.py 2012/08/31 10:40:38 10 @@ -1,23 +1,36 @@ -import subprocess - -class CommandError(subprocess.CalledProcessError): - def __init__(self,retcode,command,output): - subprocess.CalledProcessError.__init__(self,retcode,command) - self.output=output - def __str__(self): - return "Command '%s' returned non-zero exit status %d:\n%s" % (self.cmd, self.returncode,self.output) - -def execute(command, ignore_error = False, fork = False ): - stdout = subprocess.PIPE - stderr = subprocess.STDOUT - if fork: - stdout = None - stderr = None - process=subprocess.Popen(command,stdout=stdout,stderr=stderr,shell=True, universal_newlines = True,executable="/bin/bash") - if fork: - return None - output = process.communicate() - retcode = process.poll() - if retcode and not ignore_error: - raise CommandError(retcode, command, output[0]) - return output +# +# BonFIRE Virtual Clusters on Federated Clouds Demonstration Kit +# +# Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012 +# +# License GPL Version 3 +# +# The research leading to these results has received funding from +# the European Community's Seventh Framework Programme (FP7/2007-2013) +# under agreement number 257386 +# +# This software is provided with ABSOLUTELY NO WARRANTY +# +import subprocess + +class CommandError(subprocess.CalledProcessError): + def __init__(self,retcode,command,output): + subprocess.CalledProcessError.__init__(self,retcode,command) + self.output=output + def __str__(self): + return "Command '%s' returned non-zero exit status %d:\n%s" % (self.cmd, self.returncode,self.output) + +def execute(command, ignore_error = False, fork = False ): + stdout = subprocess.PIPE + stderr = subprocess.STDOUT + if fork: + stdout = None + stderr = None + process=subprocess.Popen(command,stdout=stdout,stderr=stderr,shell=True, universal_newlines = True,executable="/bin/bash") + if fork: + return None + output = process.communicate() + retcode = process.poll() + if retcode and not ignore_error: + raise CommandError(retcode, command, output[0]) + return output