#!/usr/bin/env python2 import subprocess import sys import os from DQConfig import DQConfig # Read the config file used by the job daemons c = DQConfig() acts=['start','stop','restart'] if len(sys.argv)<2 or not sys.argv[1] in acts : coms='' for c in acts: coms+='%s|'%c print 'usage: %s <%s>' % (os.path.basename(sys.argv[0]),coms[:-1]) sys.exit(1) # Each section corresponds to a daemon for section in c.cp.sections(): if not c.cp.getboolean(section,'enable'): continue p = subprocess.Popen( [ section, sys.argv[1] ],stdout=subprocess.PIPE, stderr=subprocess.PIPE ) stdout, stderr = p.communicate() print stdout print stderr retcode = p.returncode