def on_button_download(self, widget): game = self.treeview_games.get_selected_game() download_type = game.download_type install_command = game.download_url if download_type == 'wget': self.gui.show_info('<b>%s</b>\n%s' % (download_type,install_command), self.window_main) dialog = ProgressDialog(self.window_main ,'') dialog.connect("download-failed", self._fileDownloadFailed) # Download queue downloadItems = set() filedownload = os.path.join('/tmp/',game.download_url.split('/')[-1]) downloadItems.add(DownloadItem(game.game,game.download_url, filedownload)) # Try to download all items #response = dialog.download(downloadItems) dialog.message('Downloading Game...') response = dialog.download(downloadItems) if response == gtk.RESPONSE_ACCEPT: commands = game.install_command.split('|') if lib.utils.get_mimetype(filedownload) == 'application/x-tar': gunzip(filedownload) # Destroy wizard dialog.destroy() elif download_type =='deb': print 'gnome-terminal --command sudo dpkg -i %s' % game.install_command os.system('gnome-terminal --command sudo dpkg -i %s' % game.deb_filename) else: self.gui.show_info('Instalando:%s' % download_type, self.window_main)
def download_images(self, categoryid): need_download = [] cat = self.actions.get_games({'category':categoryid}) if cat: for n in cat: if load_pixbuf_image(n['image_file'])[1]: need_download.append(n) if len(need_download)>0: dialog = ProgressDialog(self.window_main ,'') dialog.connect("download-failed", self._fileDownloadFailed) # Download queue downloadItems = set() for n in need_download: downloadItems.add(DownloadItem('%s image' % n['game'], n['image_url'], os.path.join(CONFIG_DIR, n['image_file']))) # Try to download all items #response = dialog.download(downloadItems) dialog.message('Downloading Games images...') response = dialog.download(downloadItems) # Destroy wizard dialog.destroy() # Abort installation if user pressed cancel during the download #if response == gtk.RESPONSE_ACCEPT: self.window_main.set_sensitive(True)