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
OUTPUT = 'output'
OUTPUTIMAGE = 'outputimage'
PAPER = 'paper'
+PAPERSIZE = 'papersize'
PREAMBLE = 'preamble'
PRINTFILENAME = 'printfilename'
QUOTE = 'quote'
##
PAPER: {
+ PAPERSIZE: r'''#(set-paper-size "%(papersize)s")''',
INDENT: r'''indent = %(indent)s''',
LINE_WIDTH: r'''line-width = %(line-width)s''',
QUOTE: r'''line-width = %(line-width)s - 2.0 * %(exampleindent)s''',
\layout {
%(layout_string)s
}
+
+%(safe_mode_string)s
'''
elif relative > 0:
relative_quotes += "'" * relative
+ # put paper-size first, if it exists
+ for i,elem in enumerate(compose_dict[PAPER]):
+ if elem.startswith("#(set-paper-size"):
+ compose_dict[PAPER].insert(0, compose_dict[PAPER].pop(i))
+ break
+
paper_string = '\n '.join (compose_dict[PAPER]) % override
layout_string = '\n '.join (compose_dict[LAYOUT]) % override
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())
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 ()