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 14 - (view) (download) (as text)

1 : agomez 10 #
2 :     # BonFIRE Virtual Clusters on Federated Clouds Demonstration Kit
3 :     #
4 :     # Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012
5 :     #
6 : agomez 14 # License Apache Software
7 : agomez 10 #
8 :     # The research leading to these results has received funding from
9 :     # the European Community's Seventh Framework Programme (FP7/2007-2013)
10 :     # under agreement number 257386
11 :     #
12 :     # This software is provided with ABSOLUTELY NO WARRANTY
13 :     #
14 :     import subprocess
15 :    
16 :     class CommandError(subprocess.CalledProcessError):
17 :     def __init__(self,retcode,command,output):
18 :     subprocess.CalledProcessError.__init__(self,retcode,command)
19 :     self.output=output
20 :     def __str__(self):
21 :     return "Command '%s' returned non-zero exit status %d:\n%s" % (self.cmd, self.returncode,self.output)
22 :    
23 :     def execute(command, ignore_error = False, fork = False ):
24 :     stdout = subprocess.PIPE
25 :     stderr = subprocess.STDOUT
26 :     if fork:
27 :     stdout = None
28 :     stderr = None
29 :     process=subprocess.Popen(command,stdout=stdout,stderr=stderr,shell=True, universal_newlines = True,executable="/bin/bash")
30 :     if fork:
31 :     return None
32 :     output = process.communicate()
33 :     retcode = process.poll()
34 :     if retcode and not ignore_error:
35 :     raise CommandError(retcode, command, output[0])
36 :     return output

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

Powered By FusionForge