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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download) (as text)

1 : agomez 1 import subprocess
2 :    
3 :     class CommandError(subprocess.CalledProcessError):
4 :     def __init__(self,retcode,command,output):
5 :     subprocess.CalledProcessError.__init__(self,retcode,command)
6 :     self.output=output
7 :     def __str__(self):
8 :     return "Command '%s' returned non-zero exit status %d:\n%s" % (self.cmd, self.returncode,self.output)
9 :    
10 :     def execute(command, ignore_error = False, fork = False ):
11 :     stdout = subprocess.PIPE
12 :     stderr = subprocess.STDOUT
13 :     if fork:
14 :     stdout = None
15 :     stderr = None
16 :     process=subprocess.Popen(command,stdout=stdout,stderr=stderr,shell=True, universal_newlines = True,executable="/bin/bash")
17 :     if fork:
18 :     return None
19 :     output = process.communicate()
20 :     retcode = process.poll()
21 :     if retcode and not ignore_error:
22 :     raise CommandError(retcode, command, output[0])
23 :     return output

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

Powered By FusionForge