#NEWLINE# def process_json( args , out = sys . stdout ) : #NEWLINE# #INDENT# with open ( args . json , 'r' ) as content_file : #NEWLINE# #INDENT# content = content_file . read ( ) #NEWLINE# #UNINDENT# app = json . loads ( content ) #NEWLINE# validate_app ( app ) #NEWLINE# existing_apps = list_marathon_apps ( args ) #NEWLINE# previous_deploys = select_previous_deploys ( existing_apps , get_deployment_group ( app ) ) #NEWLINE# if ( len ( previous_deploys ) > 1 ) : #NEWLINE# #INDENT# if args . resume : #NEWLINE# #INDENT# logger . info ( 'Found previous deployment, resuming' ) #NEWLINE# ( old_deploy , current_deploy ) = select_last_two_deploys ( previous_deploys ) #NEWLINE# start_deployment ( args , current_deploy , old_deploy , True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'There appears to be an existing deployment in progress' ) #NEWLINE# #UNINDENT# #UNINDENT# app = prepare_deploy ( args , previous_deploys , app ) #NEWLINE# logger . info ( 'Final app definition:' ) #NEWLINE# out . write ( json . dumps ( app , sort_keys = True , indent = 2 ) ) #NEWLINE# out . write ( '\n' ) #NEWLINE# if args . dry_run : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( args . force or query_yes_no ( 'Continue with deployment?' ) ) : #NEWLINE# #INDENT# if ( len ( previous_deploys ) == 0 ) : #NEWLINE# #INDENT# start_deployment ( args , app , None , False ) #NEWLINE# #UNINDENT# if ( len ( previous_deploys ) == 1 ) : #NEWLINE# #INDENT# existing_app = select_last_deploy ( previous_deploys ) #NEWLINE# start_deployment ( args , content , existing_app , False )