@signalcommand
    def handle(self, *args, **options):
        if len(args) < 1 and not options['all_applications']:
            raise CommandError("need one or more arguments for appname")

        use_pygraphviz = options.get('pygraphviz', False)
        use_pydot = options.get('pydot', False)
        use_json = options.get('json', False)
        if use_json and (use_pydot or use_pygraphviz):
            raise CommandError("Cannot specify --json with --pydot or --pygraphviz")

        cli_options = ' '.join(sys.argv[2:])
        graph_data = generate_graph_data(args, cli_options=cli_options, **options)
        if use_json:
            self.render_output_json(graph_data, **options)
            return

        dotdata = generate_dot(graph_data)
        if not six.PY3:
            dotdata = dotdata.encode('utf-8')
        if options['outputfile']:
            if not use_pygraphviz and not use_pydot:
                if HAS_PYGRAPHVIZ:
                    use_pygraphviz = True
                elif HAS_PYDOT:
                    use_pydot = True
            if use_pygraphviz:
                self.render_output_pygraphviz(dotdata, **options)
            elif use_pydot:
                self.render_output_pydot(dotdata, **options)
            else:
                raise CommandError("Neither pygraphviz nor pydot could be found to generate the image")
        else:
            self.print_output(dotdata)
dataset/ETHPy150Open django-extensions/django-extensions/django_extensions/management/commands/graph_models.py/Command.handle/original