def OnInstall(self, e): """The user clicked on 'install'>""" index = self.worlds.GetFirstSelected() try: world = self.online[index] except IndexError: wx.MessageBox(t("ui.dialog.worlds.unknown_world"), t("ui.alert.error"), wx.OK | wx.ICON_ERROR) else: attachment = world.attachments[0] url = attachment.content_url download = Download(None, url) download.start() # Extract the world in memory archive = ZipFile(download.file) files = {name: archive.read(name) for name in archive.namelist()} wizard = InstallWorld(self.engine, "VanciaMUD", files) wizard.start()
def OnImportOndisk(self, e): """Import a world on disk.""" choose_file = t("ui.button.choose_file") extensions = "Zip archive (*.zip)|*.zip" dialog = wx.FileDialog(None, choose_file, "", "", extensions, wx.OPEN) result = dialog.ShowModal() if result == wx.ID_OK: filename = dialog.GetPath() # Try to install the world from the archive archive = ZipFile(filename) files = {name: archive.read(name) for name in archive.namelist()} options = files.get("world/options.conf") if options: infos = World.get_infos(options) name = infos.get("connection", {}).get("name") wizard = InstallWorld(self.engine, name, files) wizard.start()
def OnInstall(self, e): """The user clicked on 'install'>""" index = self.worlds.GetFirstSelected() try: world = self.online[index] except IndexError: wx.MessageBox(t("ui.dialog.worlds.unknown_world"), t("ui.alert.error"), wx.OK | wx.ICON_ERROR) else: attachment = world.attachments[0] url = attachment.content_url download = Download(None, url) download.start() # Extract the world in memory archive = ZipFile(download.file) files = {name: archive.read(name) for name in archive.namelist()} wizard = InstallWorld(self.engine, world.name, files) self.Destroy() wizard.start()
def OnDisk(self, e): """Import a world on disk.""" choose_file = t("ui.button.choose_file") extensions = "Zip archive (*.zip)|*.zip" dialog = wx.FileDialog(None, choose_file, "", "", extensions, wx.FD_OPEN) result = dialog.ShowModal() if result == wx.ID_OK: filename = dialog.GetPath() # Try to install the world from the archive archive = ZipFile(filename) files = {name: archive.read(name) for name in archive.namelist()} options = files.get("world/options.conf") if options: infos = World.get_infos(options) name = infos.get("connection", {}).get("name") wizard = InstallWorld(self.parent.engine, name, files) wizard.start() self.parent.populate_list() self.parent.worlds.SetFocus()