#!/usr/bin/python # -*- coding: utf-8 -*- import os import sys import subprocess """ This generic code used for all python scripts. The quotes are to ensure that the source .py file can still be run as a python script, but does not include any sys.path handling. Otherwise, the lilypond-book calls inside the build might modify installed .pyc files. """ for d in ['/usr/share/lilypond/2.15.25', '/usr/lib/lilypond/2.15.25']: sys.path.insert (0, os.path.join (d, 'python')) # dynamic relocation, for GUB binaries. bindir = os.path.abspath (os.path.dirname (sys.argv[0])) for p in ['share', 'lib']: datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p) sys.path.insert (0, datadir) """ """ def main(): print "**** Begin testing" cmd = "dir" ret = os.system(cmd) print "1. return code: ", ret cmd = "dir" proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) ret = proc.wait() print "2. return code: ", ret out = open('log.txt', 'w') cmd = "dir" proc = subprocess.Popen(cmd, shell=True, stdout=out) ret = proc.wait() print "3. return code: ", ret cmd = "dir" proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) ans = proc.communicate() ret = proc.returncode print "4. return code: ", ret if __name__ == '__main__': main ()