def postConversionForRetropie(self):
     self.logger.log("  retropie post-conversion")
     dosboxCfg = open(
         os.path.join(self.getLocalGameOutputDir(), "dosbox.cfg"), 'a')
     # add mount c at end of dosbox.cfg
     romsFolder = util.getRomsFolderPrefix(self.conversionType,
                                           self.conversionConf)
     retropieGameDir = romsFolder + "/" + self.genre + "/" + self.game + ".pc" if self.useGenreSubFolders else romsFolder + "/" + self.game + ".pc"
     dosboxCfg.write("mount c " + retropieGameDir + "\n")
     dosboxCfg.write("c:\n")
     # copy all instructions from dosbox.bat to end of dosbox.cfg
     dosboxBat = open(
         os.path.join(self.getLocalGameOutputDir(), "dosbox.bat"),
         'r')  # retroarch dosbox.bat
     for cmdLine in dosboxBat.readlines():
         dosboxCfg.write(cmdLine)
     # delete dosbox.bat
     dosboxCfg.close()
     dosboxBat.close()
     os.remove(os.path.join(self.getLocalGameOutputDir(), "dosbox.bat"))
     # move dosbox.cfg to {game}.conf at top level
     shutil.move(
         os.path.join(self.getLocalGameOutputDir(), "dosbox.cfg"),
         os.path.join(self.getLocalParentOutputDir(),
                      util.getCleanGameID(self.metadata, '.conf')))
Beispiel #2
0
 def __postConversionForEmuelec__(self):
     self.logger.log("  Emuelec post-conversion")
     # create pcdata and pc subfolders in outputdir
     if not os.path.exists(os.path.join(self.outputDir, 'pcdata')):
         os.mkdir(os.path.join(self.outputDir, 'pcdata'))
     if not os.path.exists(os.path.join(self.outputDir, 'pc')):
         os.mkdir(os.path.join(self.outputDir, 'pc'))
     emuElecDataDir = os.path.join(self.outputDir, 'pcdata', self.genre) if self.useGenreSubFolders \
         else os.path.join(self.outputDir, 'pcdata')
     if not os.path.exists(emuElecDataDir):
         os.mkdir(emuElecDataDir)
     # move *.pc folder to pcdata folder
     shutil.move(os.path.join(self.getLocalGameOutputDir()), emuElecDataDir)
     os.rename(os.path.join(emuElecDataDir, self.game + '.pc'),
               os.path.join(emuElecDataDir, self.game))
     open(
         os.path.join(emuElecDataDir, self.game,
                      util.getCleanGameID(self.metadata, '.bat')),
         'w').close()
     # move *.bat *.map and *.cfg to pc/*.pc folder and rename *.cfg to dosbox-SDL2.conf
     emuelecConfOutputDir = os.path.join(self.outputDir, 'pc', self.genre, self.game + ".pc") \
         if self.useGenreSubFolders else os.path.join(self.outputDir, 'pc', self.game + ".pc")
     if not os.path.exists(emuelecConfOutputDir):
         os.makedirs(emuelecConfOutputDir)
     shutil.move(os.path.join(emuElecDataDir, self.game, 'dosbox.bat'),
                 emuelecConfOutputDir)
     shutil.move(os.path.join(emuElecDataDir, self.game, 'dosbox.cfg'),
                 os.path.join(emuelecConfOutputDir, 'dosbox-SDL2.conf'))
     shutil.copy2(
         os.path.join(emuElecDataDir, self.game,
                      util.getCleanGameID(self.metadata, '.txt')),
         emuelecConfOutputDir)
     if os.path.exists(os.path.join(emuElecDataDir, self.game,
                                    'mapper.map')):
         shutil.move(os.path.join(emuElecDataDir, self.game, 'mapper.map'),
                     emuelecConfOutputDir)
     # modify dosbox-SDL2.conf to add mount c /storage/roms/pcdata/game at the beginning of autoexec.bat
     dosboxCfg = open(
         os.path.join(emuelecConfOutputDir, 'dosbox-SDL2.conf'), 'a')
     # add mount c at end of dosbox.cfg
     romsFolder = util.getRomsFolderPrefix(self.conversionType,
                                           self.conversionConf)
     emuelecGameDir = romsFolder + "/" + self.genre + "/" + self.game if self.useGenreSubFolders else romsFolder + "/" + self.game
     dosboxCfg.write("mount c " + emuelecGameDir + "\n")
     dosboxCfg.write("c:\n")
     # copy all instructions from dosbox.bat to end of dosbox.cfg
     dosboxBat = open(os.path.join(emuelecConfOutputDir, "dosbox.bat"),
                      'r')  # retroarch dosbox.bat
     for cmdLine in dosboxBat.readlines():
         # needs to get rid of '.pc' in mount instructions
         dosboxCfg.write(cmdLine.replace('.pc', ''))
     # delete dosbox.bat
     dosboxCfg.close()
     dosboxBat.close()
     # delete dosbox.bat
     os.remove(os.path.join(emuelecConfOutputDir, "dosbox.bat"))
Beispiel #3
0
    def handleMount(self, line):
        startTokens = ['a', 'b', 'd', 'e', 'f', 'g','h', 'i', 'j', 'k']
        endTokens = ['-t']
        paths, command, startIndex, endIndex = self.pathListInCommandLine(line, startTokens, endTokens)

        prString = ""
        if len(paths) == 1:
            # TESTCASE: Sidewalk (1987) / Sidewalk
            path = self.reducePath(paths[0].replace('"', ""))
            if self.gGator.isWin3x():
                # Find first game sub path and replace it
                gameSubPathIndex = path.lower().find('\\' + self.gGator.game.lower())
                gameSubPathLength = len('\\' + self.gGator.game)
                path = path[:gameSubPathIndex] + path[gameSubPathIndex + gameSubPathLength:]

            if not os.path.exists(os.path.join(self.gGator.getLocalGameOutputDir(), util.localOSPath(path))):
                self.logger.log("    <ERROR> path %s doesn't exist"
                                % os.path.join(os.path.join(self.gGator.getLocalGameOutputDir(), util.localOSPath(path))),
                                self.logger.ERROR)
            prString = prString + " " + path
        else:
            # See if path contains ""
            redoPath = " ".join(paths)
            countChar = redoPath.count('"')
            if countChar == 2:
                path = self.reducePath(paths[0].replace('"', ""))
                if self.gGator.isWin3x():
                    # Find first game sub path and replace it
                    gameSubPathIndex = path.lower().find('\\' + self.gGator.game.lower())
                    gameSubPathLength = len('\\' + self.gGator.game)
                    path = path[:gameSubPathIndex] + path[gameSubPathIndex + gameSubPathLength:]

                if not os.path.exists(os.path.join(self.gGator.getLocalGameOutputDir(), util.localOSPath(path))):
                    self.logger.log("    <ERROR> path %s doesn't exist"
                                    % os.path.join(os.path.join(self.gGator.getLocalGameOutputDir(), util.localOSPath(path))),
                                    self.logger.ERROR)
                prString = prString + " " + path
            else:
                self.logger.log("    <ERROR> MULTIPATH/MULTISPACE", self.logger.ERROR)
                self.logger.logList("    paths", paths)
                for path in paths:
                    path = self.reducePath(path.replace('"', ""))
                    if self.gGator.isWin3x():
                        # Find first game sub path and replace it
                        gameSubPathIndex = path.lower().find('\\' + self.gGator.game.lower())
                        gameSubPathLength = len('\\' + self.gGator.game)
                        path = path[:gameSubPathIndex] + path[gameSubPathIndex + gameSubPathLength:]

                    if not os.path.exists(os.path.join(self.gGator.getLocalGameOutputDir(), util.localOSPath(path))):
                        self.logger.log("    <ERROR> path %s doesn't exist"
                                        % os.path.join(os.path.join(self.gGator.getLocalGameOutputDir(), util.localOSPath(path))),
                                        self.logger.ERROR)
                    prString = prString + " " + path

        # Mount command needs to be absolute linux path
        if prString.strip().startswith('.'):
            prString = prString.strip()[1:]
        gameString = "/" + self.gGator.genre + "/" + self.gGator.game + ".pc" if self.gGator.useGenreSubFolders else "/" + self.gGator.game + ".pc"
        prString = util.getRomsFolderPrefix(self.gGator.conversionType,
                                            self.gGator.conversionConf) + gameString + prString.strip()
        prString = ' "' + prString.replace("\\", "/") + '"'
        # Needs windows absolute path for retrobat
        if self.gGator.conversionType == util.retrobat:
            prString = prString.replace("/", "\\")

        fullString = " ".join(command[0:startIndex + 1]) + prString + " " + " ".join(command[endIndex:])
        self.logger.log("    mount path: " + line.rstrip('\n\r ') + " --> " + fullString.rstrip('\n\r '))
        return fullString