#NEWLINE# def parse_args( config , host_source ) : #NEWLINE# #INDENT# args = _parse_args ( config ) #NEWLINE# args . push_id = push . utils . get_random_word ( config ) #NEWLINE# if ( args . quiet or args . auto_continue ) : #NEWLINE# #INDENT# args . hosts_before_pause = 0 #NEWLINE# #UNINDENT# ( all_hosts , aliases ) = push . hosts . get_hosts_and_aliases ( config , host_source ) #NEWLINE# args . hosts = [ ] #NEWLINE# queue = collections . deque ( args . host_refs ) #NEWLINE# while queue : #NEWLINE# #INDENT# host_or_alias = queue . popleft ( ) #NEWLINE# if hasattr ( host_or_alias , '__iter__' ) : #NEWLINE# #INDENT# queue . extend ( host_or_alias ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( ' ' in host_or_alias ) : #NEWLINE# #INDENT# queue . extend ( ( x . strip ( ) for x in host_or_alias . split ( ) ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( host_or_alias in all_hosts ) : #NEWLINE# #INDENT# args . hosts . append ( host_or_alias ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( host_or_alias in aliases ) : #NEWLINE# #INDENT# args . hosts . extend ( aliases [ host_or_alias ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ArgumentError ( ( '-h: unknown host or alias "%s"' % host_or_alias ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( args . start_at and ( args . start_at not in args . hosts ) ) : #NEWLINE# #INDENT# raise ArgumentError ( ( '--startat: host "%s" not in host list.' % args . start_at ) ) #NEWLINE# #UNINDENT# if ( args . start_at and args . shuffle and ( not args . seed ) ) : #NEWLINE# #INDENT# raise ArgumentError ( "--startat: doesn't make sense while shuffling without a seed" ) #NEWLINE# #UNINDENT# if ( args . stop_before and ( args . stop_before not in args . hosts ) ) : #NEWLINE# #INDENT# raise ArgumentError ( ( '--stopbefore: host "%s" not in host list.' % args . stop_before ) ) #NEWLINE# #UNINDENT# if ( args . stop_before and args . shuffle and ( not args . seed ) ) : #NEWLINE# #INDENT# raise ArgumentError ( "--stopbefore: doesn't make sense while shuffling without a seed" ) #NEWLINE# #UNINDENT# if ( args . start_at or args . stop_before ) : #NEWLINE# #INDENT# if args . stop_before : #NEWLINE# #INDENT# args . hosts = itertools . takewhile ( ( lambda host : ( host != args . stop_before ) ) , args . hosts ) #NEWLINE# #UNINDENT# if args . start_at : #NEWLINE# #INDENT# args . hosts = itertools . dropwhile ( ( lambda host : ( host != args . start_at ) ) , args . hosts ) #NEWLINE# #UNINDENT# args . hosts = list ( args . hosts ) #NEWLINE# #UNINDENT# if args . shuffle : #NEWLINE# #INDENT# seed = ( args . seed or args . push_id ) #NEWLINE# push . utils . seeded_shuffle ( seed , args . hosts ) #NEWLINE# #UNINDENT# args . command_line = build_command_line ( config , args ) #NEWLINE# return args