def handle(self, panel_name=None, **options):
        if panel_name is None:
            raise CommandError("You must provide a panel name.")

        if options.get('dashboard') is None:
            raise CommandError("You must specify the name of the dashboard "
                               "this panel will be registered with using the "
                               "-d or --dashboard option.")

        dashboard_path = options.get('dashboard')
        dashboard_mod_path = ".".join([dashboard_path, "dashboard"])

        # Check the dashboard.py file in the dashboard app can be imported.
        # Add the dashboard information to our options to pass along if all
        # goes well.
        try:
            dashboard_mod = import_module(dashboard_mod_path)
            options["dash_path"] = dashboard_path
            options["dash_name"] = dashboard_path.split(".")[-1]
        except ImportError:
            raise CommandError("A dashboard.py module could not be imported "
                               " from the dashboard at %r."
                               % options.get("dashboard"))

        target = options.pop("target", None)
        if target == "auto":
            target = os.path.join(os.path.dirname(dashboard_mod.__file__),
                                  panel_name)
            if not os.path.exists(target):
                try:
                    os.mkdir(target)
                except __HOLE__ as exc:
                    raise CommandError("Unable to create panel directory: %s"
                                       % exc)

        # Use our default template if one isn't specified.
        if not options.get("template", None):
            options["template"] = self.template

        # We have html templates as well, so make sure those are included.
        options["extensions"].extend(["tmpl", "html"])

        # Check that the app_name cannot be imported.
        try:
            import_module(panel_name)
        except ImportError:
            pass
        else:
            raise CommandError("%r conflicts with the name of an existing "
                               "Python module and cannot be used as an app "
                               "name. Please try another name." % panel_name)

        super(Command, self).handle('panel', panel_name, target, **options)

        if not target:
            target = os.path.join(os.curdir, panel_name)

        # Rename our python template files.
        file_names = glob.glob(os.path.join(target, "*.py.tmpl"))
        for filename in file_names:
            os.rename(filename, filename[:-5])
dataset/ETHPy150Open CiscoSystems/avos/horizon/management/commands/startpanel.py/Command.handle