From: Julien Rioux Date: Tue, 4 Oct 2011 18:37:34 +0000 (+0200) Subject: Fix a few lilypond-book bugs on windows (issue 1815). X-Git-Tag: release/2.15.15-1~47 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1ec4c90a6700825a7a126fe1ea7ea224c820c48b;p=lilypond.git Fix a few lilypond-book bugs on windows (issue 1815). - book_snippets.py: Replace os.link (purely unix) when it is unavailable by shutil.copyfile. - lilylib.py: Windows command-line arguments don't need escaping. - lilypond-book.py: Use forward slashes within lilypond files. --- diff --git a/python/book_snippets.py b/python/book_snippets.py index ab7c66e47a..e3fc2eff95 100644 --- a/python/book_snippets.py +++ b/python/book_snippets.py @@ -6,6 +6,7 @@ global _;_=ly._ import re import os import copy +import shutil # 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 @@ -639,7 +640,13 @@ printing diff against existing file." % filename) dst_path = os.path.split(dst)[0] if not os.path.isdir (dst_path): os.makedirs (dst_path) - os.link (src, dst) + try: + os.link (src, dst) + except AttributeError: + shutil.copyfile (src, dst) + except OSError: + print '\nCould not overwrite file', dst + raise CompileError(self.basename()) def additional_files_to_consider (self, base, full): return [] diff --git a/python/lilylib.py b/python/lilylib.py index e893aaa3a5..7a36a8aaac 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -150,6 +150,8 @@ please read 'Setup for MacOS X' in Application Usage.") # Modified version of the commands.mkarg(x), which always uses # double quotes (since Windows can't handle the single quotes: def mkarg(x): + if os.name == 'nt': + return x s = ' "' for c in x: if c in '\\$"`': diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 4d2b000fbd..69156d715e 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -422,7 +422,7 @@ def write_file_map (lys, name): #(define output-empty-score-list #f) #(ly:add-file-name-alist '(%s ))\n -""" % '\n'.join(['("%s.ly" . "%s")\n' % (ly.basename (), name) +""" % '\n'.join(['("%s.ly" . "%s")\n' % (ly.basename ().replace('\\','/'), name) for ly in lys])) def split_output_files(directory):