Log In | Get Help   
Home My Page Projects Code Snippets Project Openings BonFIRE VCOC Demonstration Kit
Summary Activity SCM Files Wiki
[bonfiredemokit] View of /virt-cluster/vc/vcutil.py
[bonfiredemokit] / virt-cluster / vc / vcutil.py Repository:
ViewVC logotype

View of /virt-cluster/vc/vcutil.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (download) (as text) (annotate)
Mon Aug 27 11:46:35 2012 UTC (11 years, 9 months ago) by agomez
File size: 886 byte(s)
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

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge