#!/usr/bin/python # -*- coding: utf-8 -*- import os import sys import subprocess import time """ 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 > log.txt" ret = os.system(cmd) print "0. return code: ", ret cmd = "sleep 1 && dir" proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) while proc.poll() is None: print "sleep" time.sleep(1) print "2. return code: ", ret ans = proc.communicate() print "2b. result from communicate: " print ans if __name__ == '__main__': main ()