#NEWLINE# def build_command_line( config , args ) : #NEWLINE# #INDENT# 'Given a configured environment, build a canonical command line for it.' #NEWLINE# components = [ ] #NEWLINE# components . append ( '-h' ) #NEWLINE# components . extend ( itertools . chain . from_iterable ( args . host_refs ) ) #NEWLINE# if args . start_at : #NEWLINE# #INDENT# components . append ( ( '--startat=%s' % args . start_at ) ) #NEWLINE# #UNINDENT# if args . stop_before : #NEWLINE# #INDENT# components . append ( ( '--stopbefore=%s' % args . stop_before ) ) #NEWLINE# #UNINDENT# if ( args . hosts_before_pause > 1 ) : #NEWLINE# #INDENT# components . append ( ( '--pauseafter=%s' % args . hosts_before_pause ) ) #NEWLINE# #UNINDENT# if args . fetches : #NEWLINE# #INDENT# components . append ( '-p' ) #NEWLINE# components . extend ( args . fetches ) #NEWLINE# #UNINDENT# if args . deploys : #NEWLINE# #INDENT# components . append ( '-d' ) #NEWLINE# components . extend ( args . deploys ) #NEWLINE# #UNINDENT# commands = dict ( restart = '-r' , kill = '-k' ) #NEWLINE# for command in args . deploy_commands : #NEWLINE# #INDENT# special_command = commands . get ( command [ 0 ] ) #NEWLINE# if special_command : #NEWLINE# #INDENT# components . append ( special_command ) #NEWLINE# command = command [ 1 : ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# components . append ( '-c' ) #NEWLINE# #UNINDENT# components . extend ( args ) #NEWLINE# #UNINDENT# for ( repo , rev ) in args . revisions . iteritems ( ) : #NEWLINE# #INDENT# components . extend ( ( '-rev' , repo , rev ) ) #NEWLINE# #UNINDENT# if ( not args . build_static ) : #NEWLINE# #INDENT# components . append ( '--no-static' ) #NEWLINE# #UNINDENT# if args . auto_continue : #NEWLINE# #INDENT# components . append ( '--no-input' ) #NEWLINE# #UNINDENT# if ( not args . notify_irc ) : #NEWLINE# #INDENT# components . append ( '--no-irc' ) #NEWLINE# #UNINDENT# if args . quiet : #NEWLINE# #INDENT# components . append ( '--quiet' ) #NEWLINE# #UNINDENT# if args . testing : #NEWLINE# #INDENT# components . append ( '-t' ) #NEWLINE# #UNINDENT# if args . shuffle : #NEWLINE# #INDENT# components . append ( '--shuffle' ) #NEWLINE# #UNINDENT# if args . seed : #NEWLINE# #INDENT# components . append ( ( '--seed=%s' % args . seed ) ) #NEWLINE# #UNINDENT# components . append ( ( '--sleeptime=%d' % args . sleeptime ) ) #NEWLINE# return ' ' . join ( components )