]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/book_snippets.py
Optimizations for pure-height approximations.
[lilypond.git] / python / book_snippets.py
index 443ad3c363ed5e23fbf06b099a4d81d7cfa2018d..a1b1328c575b4be2af6afe92c07d09183b9b1870 100644 (file)
@@ -6,7 +6,11 @@ global _;_=ly._
 import re
 import os
 import copy
-from subprocess import Popen, PIPE
+# TODO: We are using os.popen3, which has been deprecated since python 2.6. The
+# suggested replacement is the Popen function of the subprocess module.
+# Unfortunately, on windows this needs the msvcrt module, which doesn't seem
+# to be available in GUB?!?!?!
+# from subprocess import Popen, PIPE
 
 progress = ly.progress
 warning = ly.warning
@@ -197,6 +201,8 @@ PREAMBLE_LY = '''%%%% Generated by %(program_name)s
 \layout {
   %(layout_string)s
 }
+
+%(safe_mode_string)s
 '''
 
 
@@ -552,6 +558,10 @@ left-margin-default right-margin-default)"
         notes_string = '\n  '.join (compose_dict[NOTES]) % vars ()
         preamble_string = '\n  '.join (compose_dict[PREAMBLE]) % override
         padding_mm = self.global_options.padding_mm
+        if self.global_options.safe_mode:
+            safe_mode_string = "#(ly:set-option 'safe #t)"
+        else:
+            safe_mode_string = ""
 
         d = globals().copy()
         d.update (locals())
@@ -717,10 +727,10 @@ printing diff against existing file." % filename)
         if self.global_options.verbose:
             progress (_ ("Opening filter `%s'\n") % cmd)
 
-        #(stdin, stdout, stderr) = os.popen3 (cmd)
-
-        p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
-        (stdin, stdout, stderr) = (p.stdin, p.stdout, p.stderr)
+        # TODO: Use Popen once we resolve the problem with msvcrt in Windows:
+        (stdin, stdout, stderr) = os.popen3 (cmd)
+        p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
+        (stdin, stdout, stderr) = (p.stdin, p.stdout, p.stderr)
         stdin.write (input)
         status = stdin.close ()