<s> '''<STR_LIT>''' <EOL> from optparse import OptionParser <EOL> from dist . linux . linux_build import LinuxBuild <EOL> from dist . osx . darwin_build import DarwinBuild <EOL> from dist . windows . windows_build import WindowsBuild <EOL> from dist . errors import BuildError <EOL> import subprocess <EOL> import logging <EOL> logger = logging . getLogger ( ) <EOL> logger . addHandler ( logging . StreamHandler ( ) ) <EOL> logger . setLevel ( logging . WARNING ) <EOL> build_class = { <EOL> '<STR_LIT>' : LinuxBuild , <EOL> '<STR_LIT>' : WindowsBuild , <EOL> '<STR_LIT>' : DarwinBuild , <EOL> } <EOL> commands = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> cmd_args = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> def usage ( ) : <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' % build_class . keys ( ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> exit ( ) <EOL> def fail ( msg ) : <EOL> print '<STR_LIT>' % msg <EOL> exit ( <NUM_LIT:1> ) <EOL> def ls_dist_base ( ) : <EOL> print <EOL> print <EOL> print <EOL> print <EOL> header = "<STR_LIT>" % builder . DIST_BASE <EOL> print "<STR_LIT:*>" * len ( header ) <EOL> print header <EOL> print "<STR_LIT:*>" * len ( header ) <EOL> print <EOL> subprocess . call ( [ '<STR_LIT>' , '<STR_LIT>' , builder . DIST_BASE ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> usage = '<STR_LIT>' <EOL> desc_parts = [ '<STR_LIT>' % build_class . keys ( ) , <EOL> '<STR_LIT>' % commands , <EOL> '<STR_LIT>' % [ '<STR_LIT>' % ( k , v ) for ( k , v ) in cmd_args . iteritems ( ) ] <EOL> ] <EOL> description = '<STR_LIT:\n>' . join ( desc_parts ) <EOL> parser = OptionParser ( usage = usage , description = description ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , default = False , help = '<STR_LIT>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , default = False , help = '<STR_LIT>' ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT:url>' , default = None , help = '<STR_LIT>' ) <EOL> ( options , args ) = parser . parse_args ( ) <EOL> if options . debug : <EOL> logger . setLevel ( logging . DEBUG ) <EOL> elif options . verbose : <EOL> logger . setLevel ( logging . INFO ) <EOL> if options . url is None : <EOL> fail ( '<STR_LIT>' ) <EOL> if not len ( args ) : <EOL> parser . print_usage ( ) <EOL> exit ( ) <EOL> _url = options . url <EOL> platform = args . pop ( <NUM_LIT:0> ) <EOL> try : <EOL> builder = build_class [ platform ] <EOL> except KeyError : <EOL> fail ( '<STR_LIT>' % build_class . keys ( ) ) <EOL> buildtype = args . pop ( <NUM_LIT:0> ) <EOL> if not buildtype in commands : <EOL> fail ( '<STR_LIT>' % commands ) <EOL> logfile_hdlr = logging . FileHandler ( '<STR_LIT>' % ( platform , buildtype ) , mode = '<STR_LIT:w>' ) <EOL> logger . addHandler ( logfile_hdlr ) <EOL> try : <EOL> with builder ( buildtype , args , url = _url ) as build : <EOL> build . build ( ) <EOL> except BuildError , e : <EOL> fail ( e ) <EOL> ls_dist_base ( ) </s>
