def execute(self, options, args): if options.states or options.tags: project_list = self.workspace.get_selection_subset( states=options.states, tags=options.tags, append=False, all_=options.all, negated=options.negated) elif options.selection: project_list = self.workspace.selection else: project_list = ProjectList(self.workspace) try: current_project = self.workspace.project_in(os.getcwd()) except ProjectNotFound: try: current_project = Project.from_file( self.workspace, os.getcwd()) except NotAValidProjectException: current_project = Project(self.workspace, os.getcwd()) project_list.append(current_project) pause = options.pause summary = options.summary delimit_output = options.delimit_output results = {} for i in project_list: if delimit_output: print('\n--- START %s %s ---' % (i.relative_directory, ' '.join(args))) results[i] = self.execute_one(i, options, args) if pause: print('--- PAUSED, hit <enter> to continue, ^D to stop ---') if not sys.stdin.readline(): print('\n^D pressed, halting immediately') break if delimit_output: print('--- END %s %s ---' % (i.relative_directory, ' '.join(args))) if summary: print('\n--- SUMMARY ---') for i in project_list: print('%s %s' % (results[i], i.relative_directory), file=sys.stdout) print('--- END ---\n') success = set(results.values()) == {0} status_message = '' if success else '(despite failures)' print('Performing post command duties %s' % status_message) self.perform_post_command_duties() if success: return 0 return -1
def execute(self, args): if args.states or args.tags: project_list = self.workspace.get_selection_subset( states=args.states, tags=args.tags, append=False, all_=args.all, negated=args.negated) elif args.selection: project_list = self.workspace.selection else: project_list = ProjectList(self.workspace) try: current_project = self.workspace.project_in(os.getcwd()) except ProjectNotFound: try: current_project = Project.from_file( self.workspace, os.getcwd()) except NotAValidProjectException: current_project = Project(self.workspace, os.getcwd()) project_list.append(current_project) pause = args.pause summary = args.summary delimit_output = args.delimit_output results = {} for i in project_list: if delimit_output: print( self.format_individual_message(i, args, '\n--- START %s ---')) results[i] = self.execute_one(i, args) if pause: print('--- PAUSED, hit <enter> to continue, ^D to stop ---') if not sys.stdin.readline(): print('\n^D pressed, halting immediately') break if delimit_output: print( self.format_individual_message(i, args, '\n--- END %s ---')) if summary: print('\n--- SUMMARY ---') for i in project_list: print('%s %s' % (results[i], i.relative_directory), file=sys.stdout) print('--- END ---\n') success = set(results.values()) == {0} if success: return 0 return 1