#NEWLINE# def main( **kwargs ) : #NEWLINE# #INDENT# "\n    Entry point for dx-build-app(let).\n\n    Don't call this function as a subroutine in your program! It is liable to\n    sys.exit your program when it detects certain error conditions, so you\n    can't recover from those as you could if it raised exceptions. Instead,\n    call dx_build_app.build_and_upload_locally which provides the real\n    implementation for dx-build-app(let) but is easier to use in your program.\n    " #NEWLINE# if ( len ( sys . argv ) > 0 ) : #NEWLINE# #INDENT# if sys . argv [ 0 ] . endswith ( 'dx-build-app' ) : #NEWLINE# #INDENT# logging . warn ( 'Warning: dx-build-app has been replaced with "dx build --create-app". Please update your scripts.' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if sys . argv [ 0 ] . endswith ( 'dx-build-applet' ) : #NEWLINE# #INDENT# logging . warn ( 'Warning: dx-build-applet has been replaced with "dx build". Please update your scripts.' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( len ( kwargs ) == 0 ) : #NEWLINE# #INDENT# args = parser . parse_args ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# args = parser . parse_args ( ** kwargs ) #NEWLINE# #UNINDENT# if ( ( dxpy . AUTH_HELPER is None ) and ( not args . dry_run ) ) : #NEWLINE# #INDENT# parser . error ( 'Authentication required to build an executable on the platform; please run "dx login" first' ) #NEWLINE# #UNINDENT# if ( args . src_dir is None ) : #NEWLINE# #INDENT# args . src_dir = os . getcwd ( ) #NEWLINE# if USING_PYTHON2 : #NEWLINE# #INDENT# args . src_dir = args . src_dir . decode ( sys . getfilesystemencoding ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( args . mode == 'app' ) and ( args . destination != '.' ) ) : #NEWLINE# #INDENT# parser . error ( '--destination cannot be used when creating an app (only an applet)' ) #NEWLINE# #UNINDENT# if ( ( args . mode == 'applet' ) and args . region ) : #NEWLINE# #INDENT# parser . error ( '--region cannot be used when creating an applet (only an app)' ) #NEWLINE# #UNINDENT# if ( args . dx_toolkit_autodep in [ 'beta' , 'unstable' ] ) : #NEWLINE# #INDENT# logging . warn ( 'The --dx-toolkit-beta-autodep and --dx-toolkit-unstable-autodep flags have no effect and will be removed at some date in the future.' ) #NEWLINE# #UNINDENT# if ( args . overwrite and args . archive ) : #NEWLINE# #INDENT# parser . error ( 'Options -f/--overwrite and -a/--archive cannot be specified together' ) #NEWLINE# #UNINDENT# if ( ( args . run is not None ) and args . dry_run ) : #NEWLINE# #INDENT# parser . error ( 'Options --dry-run and --run cannot be specified together' ) #NEWLINE# #UNINDENT# if ( args . run and args . remote and ( args . mode == 'app' ) ) : #NEWLINE# #INDENT# parser . error ( 'Options --remote, --app, and --run cannot all be specified together. Try removing --run and then separately invoking dx run.' ) #NEWLINE# #UNINDENT# executable_id = _build_app ( args , ( json . loads ( args . extra_args ) if args . extra_args else { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# if ( args . run is not None ) : #NEWLINE# #INDENT# if ( executable_id is None ) : #NEWLINE# #INDENT# raise AssertionError ( 'Expected executable_id to be set here' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# subprocess . check_call ( ( [ 'dx' , 'run' , executable_id , '--priority' , 'high' ] + args . run ) ) #NEWLINE# #UNINDENT# except subprocess . CalledProcessError as e : #NEWLINE# #INDENT# sys . exit ( e . returncode ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# err_exit ( ) #NEWLINE# #UNINDENT# #UNINDENT# return