Use check_call

parent 42a64bd0
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
import os import os
from slapos import slap from slapos import slap
import signal import signal
import subprocess
from subprocess import Popen from subprocess import Popen
import sys import sys
import time import time
...@@ -44,32 +45,35 @@ def runAccords(accords_conf): ...@@ -44,32 +45,35 @@ def runAccords(accords_conf):
key_file = accords_conf['key_file'] key_file = accords_conf['key_file']
cert_file = accords_conf['cert_file'] cert_file = accords_conf['cert_file']
accords_lib_directory = accords_conf['accords_lib_directory'] accords_lib_directory = accords_conf['accords_lib_directory']
poc_location = accords_conf['poc_location'] accords_location = accords_conf['accords_location']
manifest_name = accords_conf['manifest_name'] manifest_name = accords_conf['manifest_name']
environment = dict( environment = dict(
LD_LIBRARY_PATH=accords_lib_directory, LD_LIBRARY_PATH=accords_lib_directory,
PATH= accords_conf['path'], PATH=accords_conf['path'],
HOME=accords_location,
) )
# Set handler to stop ACCORDS when end of world comes # Set handler to stop ACCORDS when end of world comes
# XXX use subprocess.check_call and add exception handlers
def sigtermHandler(signum, frame): def sigtermHandler(signum, frame):
Popen(['./co-command', 'stop', '/service/*'], Popen(['./co-command', 'stop', '/service/*'],
cwd=poc_location, env=environment).communicate() cwd=accords_location, env=environment).communicate()
Popen(['./co-stop'], Popen(['./co-stop'],
cwd=poc_location, env=environment).communicate() cwd=accords_location, env=environment).communicate()
sys.exit(0) sys.exit(0)
signal.signal(signal.SIGTERM, sigtermHandler) signal.signal(signal.SIGTERM, sigtermHandler)
# Launch ACCORDS, parse & broke manifest to deploy instance # Launch ACCORDS, parse & broke manifest to deploy instance
Popen(['./co-start'],cwd=poc_location, env=environment).communicate() print 'Starting ACCORDS and friends...'
subprocess.check_call(['./co-start'],cwd=accords_location, env=environment)
print 'Parsing manifest...' print 'Parsing manifest...'
Popen(['./co-parser', manifest_name], subprocess.check_call(['./co-parser', manifest_name],
cwd=poc_location, env=environment).communicate() cwd=accords_location, env=environment)
print 'Brokering manifest...' print 'Brokering manifest...'
Popen(['./co-broker', manifest_name], subprocess.check_call(['./co-broker', manifest_name],
cwd=poc_location, env=environment).communicate() cwd=accords_location, env=environment)
print 'Done.' print 'Done.'
# Parse answer # Parse answer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment