#!/usr/bin/python # -*- coding: utf-8 -*- import os import sys import tempfile """ 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" tempdir = tempfile.mkdtemp() print "Using temporary directory: %s" % tempdir filename = os.path.join(tempdir, 'output.txt') print "Attempting to save data to %s" % filename print cmd = "dir > %s" % filename ret = os.system(cmd) print "0. return code: ", ret data = open(filename).read() print "got data: %s" % data print print "cleaning up" os.remove(filename) os.rmdir(tempdir) if __name__ == '__main__': main ()