def __handle_indexed_roms(self, disk_prefix, names, emu_params, rom,
                              temp_dir):
        log.info("ArchiveHandler.__handle_indexed_roms")
        if disk_prefix == '':
            return None

        match = re.search(disk_prefix.lower(), str(names).lower())

        if '%I%' not in emu_params or not match:
            return None

        log.info("Extracting %d files" % len(names))

        try:
            extracted_files = self.__extract_files(rom, names, temp_dir)
        except Exception as exc:
            log.error("Error handling compressed file: " + str(exc))
            return None

        if extracted_files is None:
            log.warning("Error handling compressed file")
            return None

        return extracted_files
Ejemplo n.º 2
0
        match = False
        if self.romCollection.diskPrefix != '':
            match = re.search(self.romCollection.diskPrefix.lower(),
                              str(names).lower())

        if '%I%' in emuParams and match:
            log.info("Loading %d archives" % len(names))

            try:
                archives = self.__getArchives(filext, rom, names)
            except Exception, (exc):
                log.error("Error handling compressed file: " + str(exc))
                return []

            if archives is None:
                log.warning("Error handling compressed file")
                return []
            for archive in archives:
                newPath = os.path.join(tempDir, archive[0])
                fp = open(newPath, 'wb')
                fp.write(archive[1])
                fp.close()
                roms.append(newPath)

        elif len(names) > 1:
            log.info("The Archive has %d files" % len(names))
            chosenROM = xbmcgui.Dialog().select('Choose a ROM', names)
        elif len(names) == 1:
            log.info("Archive only has one file inside; picking that one")
            chosenROM = 0
        else:
Ejemplo n.º 3
0
    def __handleCompressedFile(self, gui, filext, rom, emuParams):

        log.info("__handleCompressedFile")

        # Note: Trying to delete temporary files (from zip or 7z extraction) from last run
        # Do this before launching a new game. Otherwise game could be deleted before launch
        tempDir = os.path.join(util.getTempDir(), 'extracted', self.romCollection.name)
        # check if folder exists
        if not xbmcvfs.exists(tempDir + '\\'):
            log.info("Create temporary folder: " + tempDir)
            xbmcvfs.mkdir(tempDir)

        try:
            if xbmcvfs.exists(tempDir + '\\'):
                log.info("Trying to delete temporary rom files")
                #can't use xbmcvfs.listdir here as it seems to cache the file list and RetroPlayer won't find newly created files anymore
                files = os.listdir(tempDir)
                for f in files:
                    #RetroPlayer places savestate files next to the roms. Don't delete these files.
                    fname, ext = os.path.splitext(f)
                    if ext not in ('.sav', '.xml', '.png'):
                        xbmcvfs.delete(os.path.join(tempDir, f))
        except Exception as exc:
            log.error("Error deleting files after launch emu: " + str(exc))
            gui.writeMsg(util.localize(32036) + ": " + str(exc))

        roms = []

        log.info("Treating file as a compressed archive")

        try:
            names = self.__getNames(filext, rom)
        except Exception as exc:
            log.error("Error handling compressed file: " + str(exc))
            return []

        if names is None:
            log.error("Error handling compressed file")
            return []

        chosenROM = -1

        # check if we should handle multiple roms
        match = False
        if self.romCollection.diskPrefix != '':
            match = re.search(self.romCollection.diskPrefix.lower(), str(names).lower())

        if '%I%' in emuParams and match:
            log.info("Loading %d archives" % len(names))

            try:
                archives = self.__getArchives(filext, rom, names)
            except Exception as exc:
                log.error("Error handling compressed file: " + str(exc))
                return []

            if archives is None:
                log.warning("Error handling compressed file")
                return []
            for archive in archives:
                newPath = os.path.join(tempDir, archive[0])
                fp = open(newPath, 'wb')
                fp.write(archive[1])
                fp.close()
                roms.append(newPath)

        elif len(names) > 1:
            log.info("The Archive has %d files" % len(names))
            chosenROM = xbmcgui.Dialog().select('Choose a ROM', names)
        elif len(names) == 1:
            log.info("Archive only has one file inside; picking that one")
            chosenROM = 0
        else:
            log.error("Archive had no files inside!")
            return []

        if chosenROM != -1:
            # Extract all files to %TMP%
            archives = self.__getArchives(filext, rom, names)
            if archives is None:
                log.warn("Error handling compressed file")
                return []
            for archive in archives:
                newPath = os.path.join(tempDir, archive[0])
                log.info("Putting extracted file in %s" % newPath)
                fo = open(str(newPath), 'wb')
                fo.write(archive[1])
                fo.close()

            # Point file name to the chosen file and continue as usual
            roms = [os.path.join(tempDir, names[chosenROM])]

        return roms
Ejemplo n.º 4
0
		# check if we should handle multiple roms
		match = False
		if self.romCollection.diskPrefix != '':
			match = re.search(self.romCollection.diskPrefix.lower(), str(names).lower())

		if '%I%' in emuParams and match:
			log.info("Loading %d archives" % len(names))

			try:
				archives = self.__getArchives(filext, rom, names)
			except Exception, (exc):
				log.error("Error handling compressed file: " +str(exc))
				return []

			if archives is None:
				log.warning("Error handling compressed file")
				return []
			for archive in archives:
				newPath = os.path.join(tempDir, archive[0])
				fp = open(newPath, 'wb')
				fp.write(archive[1])
				fp.close()
				roms.append(newPath)

		elif len(names) > 1:
			log.info("The Archive has %d files" % len(names))
			chosenROM = xbmcgui.Dialog().select('Choose a ROM', names)
		elif len(names) == 1:
			log.info("Archive only has one file inside; picking that one")
			chosenROM = 0
		else: