Changeset 1:832ec3939518

Show
Ignore:
Timestamp:
02/04/07 22:37:06 (19 months ago)
Author:
paniq
Branch:
trunk
Message:

[svn] added --profile run option

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • share/aldrin/main.py

    r0 r1  
    446446 
    447447        import sys 
    448         if len(sys.argv) > 1: 
    449             self.open_file(sys.argv[1]) 
     448        if len(app_args) > 1: 
     449            self.open_file(app_args[1]) 
    450450        if audiotrouble: 
    451451            wx.MessageDialog(self, message="Aldrin tried to guess an audio driver but that didn't work. You need to select your own. Hit OK to show the preferences dialog.", caption = "Aldrin", style = wx.ICON_ERROR|wx.OK|wx.CENTER).ShowModal() 
     
    17061706        return 1 
    17071707 
    1708 def run(argv): 
    1709     """ 
    1710     Starts the application and runs the mainloop. 
    1711      
    1712     @param argv: command line arguments as passed by sys.argv. 
    1713     @type argv: str list 
    1714     """ 
    1715     global app 
     1708from optparse import OptionParser 
     1709parser = OptionParser() 
     1710parser.add_option("--profile", metavar="profile", default='', help="Start Aldrin with profiling enabled, save results to <profile>.") 
     1711app_options = None 
     1712app_args = None 
     1713 
     1714def main(): 
    17161715    app = AldrinApplication(0) 
    17171716    app.MainLoop() 
     
    17211720        player.mididriver_close_all() 
    17221721        driver.get_audiodriver().destroy() 
     1722 
     1723def run(argv): 
     1724    """ 
     1725    Starts the application and runs the mainloop. 
     1726     
     1727    @param argv: command line arguments as passed by sys.argv. 
     1728    @type argv: str list 
     1729    """ 
     1730    global app 
     1731    global app_options 
     1732    global app_args 
     1733    app_options, app_args = parser.parse_args(argv) 
     1734    if app_options.profile: 
     1735        import profile 
     1736        profile.runctx('main()', globals(), locals(), app_options.profile) 
     1737    else: 
     1738        main() 
    17231739 
    17241740__all__ = [ 
     
    17311747'TimePanel', 
    17321748'AldrinApplication', 
     1749'main', 
    17331750'run', 
    17341751]