Exemplo n.º 1
0
    def _show_plugin_wizard_dialog(self):
        from mapclient.tools.pluginwizard.wizarddialog import WizardDialog
        from mapclient.tools.pluginwizard.skeleton import Skeleton

        om = self._model.optionsManager()

        dlg = WizardDialog(self)
        dlg.setPreviousWriteStepLocation(
            om.getOption(PREVIOUS_PW_WRITE_STEP_LOCATION))
        dlg.setPreviousIconLocation(om.getOption(PREVIOUS_PW_ICON_LOCATION))

        dlg.setModal(True)
        if dlg.exec_() == dlg.Accepted:
            om.setOption(PREVIOUS_PW_WRITE_STEP_LOCATION,
                         dlg.getPreviousWriteStepLocation())
            om.setOption(PREVIOUS_PW_ICON_LOCATION,
                         dlg.getPreviousIconLocation())

            s = Skeleton(dlg.getOptions(), self._create_qt_tools_options())
            try:
                s.write()
                pm = self._model.pluginManager()
                pm.setReloadPlugins()
                self._plugin_manager_load_plugins()
                QtWidgets.QMessageBox.information(
                    self, 'Skeleton Step',
                    'The Skeleton step has successfully been written to disk.')
            except Exception as e:
                QtWidgets.QMessageBox.critical(
                    self, 'Error Writing Step',
                    'There was an error writing the step, perhaps the step already exists?'
                )
                logger.critical(e)
                import os
                package_directory = s.getPackageDirectory()
                if os.path.exists(package_directory):
                    logger.info(
                        'Removing partially created skeleton step "{0}"'.
                        format(package_directory))
                    import shutil
                    shutil.rmtree(package_directory)