@@ -119,19 +119,31 @@ def getAbsolutePitch(self):
119119
120120 return pitch , token
121121
122+ def runConvertLy (lilypond , lyFile , newLyFile ):
123+ if sys .platform .startswith ("win" ):
124+ # rc = os.system("python %sconvert-ly.py '%s' >> '%s'"
125+ # % (lilypond, lyFile, newLyFile))
122126
123- def preprocessLyFile (lyFile , lilypondVersion ):
127+ rc = 1 # for now error out so that converted.ly is created by copy
128+ else :
129+ rc = os .system ("convert-ly '%s' >> '%s'" % (lyFile , newLyFile ))
130+
131+ if rc :
132+ warn ("Convert of input file has failed. " +
133+ "This could cause some problems." )
134+
135+ return rc
136+
137+ def preprocessLyFile (lilypond , lyFile , lilypondVersion ):
124138 version = getLyVersion (lyFile )
125139 progress ("Version in %s: %s" %
126140 (lyFile , version if version else "unspecified" ))
127141 if version and version != lilypondVersion :
128142 progress ("Will convert to: %s" % lilypondVersion )
129143 newLyFile = tmpPath ('converted.ly' )
130- if os .system ("convert-ly '%s' >> '%s'" % (lyFile , newLyFile )) == 0 :
144+ if runConvertLy (lilypond , lyFile , newLyFile ) == 0 :
145+ print ('convertly success' )
131146 return newLyFile
132- else :
133- warn ("Convert of input file has failed. " +
134- "This could cause some problems." )
135147
136148 newLyFile = tmpPath ('unconverted.ly' )
137149
@@ -922,19 +934,19 @@ def parseOptions():
922934 group_os = parser .add_argument_group (title = 'External programs' )
923935
924936 group_os .add_argument (
925- "--windows- lilypond" , dest = "winLilypond " ,
926- help = '(for Windows users) folder with lilypond.exe '
937+ "--lilypond" , dest = "lilypond " ,
938+ help = 'folder with lilypond executable '
927939 '(e.g. "C:\\ lilypond\\ bin\\ ")' ,
928940 metavar = "PATH" , default = "" )
929941 group_os .add_argument (
930- "--windows- ffmpeg" , dest = "winFfmpeg " ,
931- help = '(for Windows users) folder with ffpeg.exe '
942+ "--ffmpeg" , dest = "ffmpeg " ,
943+ help = 'folder with ffmpeg executable '
932944 '(e.g. "C:\\ ffmpeg\\ bin\\ ")' ,
933945 metavar = "PATH" , default = "" )
934946 group_os .add_argument (
935- "--windows- timidity" , dest = "winTimidity " ,
936- help = '(for Windows users) folder with '
937- 'timidity.exe (e.g. "C:\\ timidity\\ ")' ,
947+ "--timidity" , dest = "timidity " ,
948+ help = 'folder with timidity executable '
949+ ' (e.g. "C:\\ timidity\\ ")' ,
938950 metavar = "PATH" , default = "" )
939951
940952 group_debug = parser .add_argument_group (title = 'Debug' )
@@ -1565,19 +1577,14 @@ def main():
15651577 # we'll have somewhere nice to save state.
15661578 global runDir
15671579 runDir = os .getcwd ()
1568- setRunDir (runDir )
1569-
1570- # Delete old temporary files.
1571- if os .path .isdir (tmpPath ()):
1572- shutil .rmtree (tmpPath ())
1573- os .mkdir (tmpPath ())
1580+ setRunDir (runDir ) # runDir is needed for lilypond includes
15741581
15751582 # .ly input file from user (string)
15761583 lyFile = options .input
15771584
15781585 # If the input .ly doesn't match the currently installed LilyPond
15791586 # version, try to convert it
1580- lyFile = preprocessLyFile (lyFile , lilypondVersion )
1587+ lyFile = preprocessLyFile (options . lilypond , lyFile , lilypondVersion )
15811588
15821589 # https://pillow.readthedocs.io/en/5.1.x/releasenotes/5.0.0.html#decompression-bombs-now-raise-exceptions
15831590 Image .MAX_IMAGE_PIXELS = None
0 commit comments