]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/lilylib.py
* lily/note-collision.cc (check_meshing_chords): if merging heads,
[lilypond.git] / python / lilylib.py
index 466d77447f4df88bc6cac63f201b4fe88b1cb735..ba339854bccbdd17244d1a22bc91a7bda353db77 100644 (file)
@@ -153,9 +153,9 @@ def option_help_str (o):
        if o[1]:
                sh = '-%s' % o[1]
 
-       sep = ' '
+       sep = '  '
        if o[1] and o[2]:
-               sep = ','
+               sep = ', '
                
        long = ''
        if o[2]:
@@ -234,17 +234,20 @@ def setup_temp ():
        return __main__.temp_dir
 
 def command_name (cmd):
-       return re.match ('^[ \t]*([^ \t]*)', cmd).group (1)
+       return re.match ('^[^a-z0-9_-]*([a-z0-9_-]*)', cmd).group (1)
 
 def error_log (name):
-       name = re.sub('[/:]','x',name)
+       name = re.sub('[^a-z]','x',name)
        return tempfile.mktemp ('%s.errorlog' % name)
 
 def read_pipe (cmd, mode = 'r'):
+       
+       
        redirect = ''
        error_log_file = ''
        if __main__.verbose_p:
                progress (_ ("Opening pipe `%s\'") % cmd)
+       else:
                error_log_file = error_log (command_name (cmd))
                redirect = ' 2>%s' % error_log_file
                
@@ -259,9 +262,17 @@ def read_pipe (cmd, mode = 'r'):
 
        if status:
                error (_ ("`%s\' failed (%d)") % (cmd, exit_status))
+               
                if not __main__.verbose_p:
-                       error (_ ("The error log is as follows:"))
-                       sys.stderr.write (open (error_log (command_name (cmd)).read ()))
+                       contents = open (error_log_file).read ()
+                       if contents:
+                               error (_ ("The error log is as follows:"))
+                               sys.stderr.write (contents)
+
+               # Ugh. code dup
+               if error_log_file:
+                       os.unlink (error_log_file)
+
                exit (status)
                
        if __main__.verbose_p:
@@ -282,7 +293,8 @@ RETURN VALUE
 Exit status of CMD '''
 
        name = command_name (cmd)
-
+       error_log_file = ''
+       
        if __main__.verbose_p:
                progress_p = 1
                progress (_ ("Invoking `%s\'") % cmd)
@@ -291,10 +303,11 @@ Exit status of CMD '''
 
        redirect = ''
        if not progress_p:
-               redirect = ' 1>/dev/null 2>' + error_log (name)
+               error_log_file = error_log (name)
+               redirect = ' 1>/dev/null 2>' + error_log_file
        elif __main__.pseudo_filter_p:
                redirect = ' 1>/dev/null'
-                       
+
        status = os.system (cmd + redirect)
        signal = 0x0f & status
        exit_status = status >> 8
@@ -311,11 +324,15 @@ Exit status of CMD '''
                                warning (msg + ' ' + _ ("(ignored)"))
                else:
                        error (msg)
-                       if not progress_p:
+                       if not progress_p and error_log_file:
                                error (_ ("The error log is as follows:"))
-                               sys.stderr.write (open (error_log (name)).read ())
+                               sys.stderr.write (error_log_file).read ()
+                       if error_log_file:
+                               os.unlink (error_log_file)
                        exit (status)
 
+       if error_log_file:
+               os.unlink (error_log_file)
        progress ('\n')
        return status