def test_DBUpgrade(self):
        from gamedatabase import GameDataBase

        db_path = os.path.join(self.get_testdata_path(), 'dbupgrade')

        # Setup data - MyGames.db is the hard-coded expected DB name
        self.assertTrue(
            os.path.isfile(os.path.join(db_path, 'MyGames-0.7.4.db')),
            "Expected to find 0.7.4 DB")
        shutil.copyfile(os.path.join(db_path, 'MyGames-0.7.4.db'),
                        os.path.join(db_path, 'MyGames.db'))

        gdb = GameDataBase(db_path)
        gdb.connect()

        #create db if not existent and maybe update to new version
        gdb.checkDBStructure()
        gdb.close()

        # Check backup files were created
        self.assertTrue(
            os.path.isfile(os.path.join(db_path, 'MyGames.db.backup 0.7.4')),
            "No backup database created")

        # FIXME TODO Assert version is 0.7.5
        # FIXME TODO Assert no data lost (num of rows for games, publishers, etc, is correct)

        # Cleanup
        os.remove(os.path.join(db_path, 'MyGames.db'))
        os.remove(os.path.join(db_path, 'MyGames.db.backup 0.7.4'))
Пример #2
0
    def test_exportLibrary(self):

        export_base_folder = './testdata/nfo/export/'
        xbmcaddon._settings['rcb_nfoFolder'] = export_base_folder

        # Setup data - MyGames.db is the hard-coded expected DB name
        db_path = './testdata/database/'
        shutil.copyfile(os.path.join(db_path, 'MyGames_2.2.0_full.db'), os.path.join(db_path, 'MyGames.db'))
        gdb = GameDataBase(db_path)
        gdb.connect()

        # Setup config
        config_xml_file = './testdata/config/romcollections_importtests.xml'
        conf = Config(config_xml_file)
        conf.readXml()

        writer = NfoWriter()
        writer.exportLibrary(gdb, conf.romCollections)

        #check if all files have been created
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'Amiga/Airborne Ranger.nfo')))
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'Amiga/Chuck Rock.nfo')))
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'Amiga/Eliminator.nfo')))
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'Amiga/MicroProse Formula One Grand Prix.nfo')))
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'Atari 2600/Adventure (1980) (Atari).nfo')))
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'Atari 2600/Air-Sea Battle (32 in 1) (1988) (Atari) (PAL).nfo')))
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'Atari 2600/Asteroids (1981) (Atari) [no copyright].nfo')))
        #FIXME TODO: can't find file even if it exists
        #self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'Nintendo 64/1080° Snowboarding.nfo')))
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'PlayStation/Bushido Blade.nfo')))
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'PlayStation/Silent Hill.nfo')))
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'SNES/Chrono Trigger.nfo')))
        self.assertTrue(os.path.isfile(os.path.join(export_base_folder, "SNES/Madden NFL '97.nfo")))

        os.remove(os.path.join(export_base_folder, 'Amiga/Airborne Ranger.nfo'))
        os.remove(os.path.join(export_base_folder, 'Amiga/Chuck Rock.nfo'))
        os.remove(os.path.join(export_base_folder, 'Amiga/Eliminator.nfo'))
        os.remove(os.path.join(export_base_folder, 'Amiga/MicroProse Formula One Grand Prix.nfo'))
        os.remove(os.path.join(export_base_folder, 'Atari 2600/Adventure (1980) (Atari).nfo'))
        os.remove(os.path.join(export_base_folder, 'Atari 2600/Air-Sea Battle (32 in 1) (1988) (Atari) (PAL).nfo'))
        os.remove(os.path.join(export_base_folder, 'Atari 2600/Asteroids (1981) (Atari) [no copyright].nfo'))
        #FIXME TODO: can't find file even if it exists
        #os.remove(os.path.join(export_base_folder, 'Nintendo 64/1080° Snowboarding.nfo'))
        os.remove(os.path.join(export_base_folder, 'PlayStation/Bushido Blade.nfo'))
        os.remove(os.path.join(export_base_folder, 'PlayStation/Silent Hill.nfo'))
        os.remove(os.path.join(export_base_folder, 'SNES/Chrono Trigger.nfo'))
        os.remove(os.path.join(export_base_folder, "SNES/Madden NFL '97.nfo"))

        gdb.close()
        os.remove(os.path.join(db_path, 'MyGames.db'))
    def test_DBUpgrade_074_221(self):
        db_path = os.path.join(self.get_testdata_path(), 'database')

        # Setup data - MyGames.db is the hard-coded expected DB name
        self.assertTrue(
            os.path.isfile(os.path.join(db_path, 'MyGames-0.7.4.db')),
            "Expected to find 0.7.4 DB")
        shutil.copyfile(os.path.join(db_path, 'MyGames-0.7.4.db'),
                        os.path.join(db_path, 'MyGames.db'))

        gdb = GameDataBase(db_path)
        gdb.connect()

        util.CURRENT_DB_VERSION = '2.2.1'
        # Create db if not existent and maybe update to new version
        gdb.checkDBStructure()

        # Check backup files were created
        self.assertTrue(
            os.path.isfile(os.path.join(db_path, 'MyGames.db.backup 0.7.4')),
            "No backup database created")

        rcbSettingRows = RCBSetting(gdb).getAll()
        self.assertEquals('2.2.1', rcbSettingRows[0][RCBSetting.COL_dbVersion])
        self.assertEquals(117, Game(gdb).getCount())

        # Cleanup
        gdb.close()
        os.remove(os.path.join(db_path, 'MyGames.db'))
        os.remove(os.path.join(db_path, 'MyGames.db.backup 0.7.4'))
    def test_DBUpgrade(self):
        from gamedatabase import GameDataBase

        db_path = os.path.join (self.get_testdata_path(), 'dbupgrade')

        # Setup data - MyGames.db is the hard-coded expected DB name
        self.assertTrue(os.path.isfile(os.path.join (db_path, 'MyGames-0.7.4.db')), "Expected to find 0.7.4 DB")
        shutil.copyfile(os.path.join (db_path, 'MyGames-0.7.4.db'), os.path.join (db_path, 'MyGames.db'))

        gdb = GameDataBase(db_path)
        gdb.connect()

        #create db if not existent and maybe update to new version
        gdb.checkDBStructure()
        gdb.close()

        # Check backup files were created
        self.assertTrue(os.path.isfile(os.path.join (db_path, 'MyGames.db.backup 0.7.4')), "No backup database created")

        # FIXME TODO Assert version is 0.7.5
        # FIXME TODO Assert no data lost (num of rows for games, publishers, etc, is correct)

        # Cleanup
        os.remove(os.path.join (db_path, 'MyGames.db'))
        os.remove(os.path.join (db_path, 'MyGames.db.backup 0.7.4'))
    def setUpClass(cls):
        # Open the DB
        db_path = os.path.join(cls.get_testdata_path(), 'database')

        # Setup data - MyGames.db is the hard-coded expected DB name
        shutil.copyfile(os.path.join(db_path, 'MyGames_current_117_games.db'), os.path.join(db_path, 'MyGames.db'))

        cls.gdb = GameDataBase(db_path)
        cls.gdb.connect()
Пример #6
0
	def launchGame(self, param):
		import launcher, util
		from gamedatabase import GameDataBase
		from config import Config
		
		gdb = GameDataBase(util.getAddonDataPath())
		gdb.connect()
		
		gameId = int(param.replace('launchid=', ''))
		
		config = Config(None)
		statusOk, errorMsg = config.readXml()
		
		settings = util.getSettings()
		
		gui = dummyGUI()
		
		launcher.launchEmu(gdb, gui, gameId, config, settings, None)
Пример #7
0
    def launchGame(self, param):
        import util
        from launcher import RCBLauncher
        from gamedatabase import GameDataBase
        from config import Config

        gdb = GameDataBase(util.getAddonDataPath())
        gdb.connect()

        #HACK if invoked from widget addon there is an additional ? in param
        param = param.replace('?', '')
        gameId = int(param.replace('launchid=', ''))

        config = Config(None)
        config.readXml()

        gui = dummyGUI()

        RCBLauncher().launchEmu(gdb, gui, gameId, config, None)
Пример #8
0
	def launchGame(self, param):
		import util
		from launcher import RCBLauncher
		from gamedatabase import GameDataBase
		from config import Config

		gdb = GameDataBase(util.getAddonDataPath())
		gdb.connect()

		#HACK if invoked from widget addon there is an additional ? in param
		param = param.replace('?', '')
		gameId = int(param.replace('launchid=', ''))

		config = Config(None)
		statusOk, errorMsg = config.readXml()

		gui = dummyGUI()

		RCBLauncher().launchEmu(gdb, gui, gameId, config, None)
Пример #9
0
def runUpdate():
    xbmc.log('RCB: runUpdate')

    gdb = GameDataBase(util.getAddonDataPath())
    gdb.connect()
    #create db if not existent and maybe update to new version
    gdb.checkDBStructure()

    configFile = config.Config(None)
    configFile.readXml()

    selectedRomCollection = ''
    selectedScraper = ''

    xbmc.log('RCB: parameters = %s' % sys.argv)
    for arg in sys.argv:
        param = str(arg)
        xbmc.log('RCB: param = %s' % param)

        if 'selectedRomCollection' in param:
            selectedRomCollection = param.replace('selectedRomCollection=', '')
        if 'selectedScraper' in param:
            selectedScraper = param.replace('selectedScraper=', '')

    romCollections = configFile.romCollections
    if selectedRomCollection and selectedScraper:
        romCollections = prepareRomCollections(configFile, selectedRomCollection, selectedScraper)

    progress = ProgressDialogBk()
    progress.create('Rom Collection Browser', 'Update DB')

    with HandleAbort():
        dbupdate.DBUpdate().updateDB(gdb, progress, romCollections, False)

    progress.close()
Пример #10
0
    def setUp(cls):
        # This is required so that readScraper() can parse the XML instruction files
        util.RCBHOME = os.path.join(os.path.dirname(__file__), '..', '..')

        # Open the DB
        db_path = os.path.join(cls.get_testdata_path(), 'database')

        # Setup data - MyGames.db is the hard-coded expected DB name
        shutil.copyfile(os.path.join(db_path, 'MyGames_2.2.0_full.db'),
                        os.path.join(db_path, 'MyGames.db'))

        cls.gdb = GameDataBase(db_path)
        cls.gdb.connect()
Пример #11
0
    def openDbConnection(self):
        xbmc.log('RCB widget: openDbConnection')

        gdb = GameDataBase(util.getAddonDataPath())
        gdb.connect()

        doImport, errorMsg = gdb.checkDBStructure()
        if (doImport) > 0:
            xbmc.log(
                "RCB widget: No database available. Won't gather any data.")
            gdb.close()
            return
        elif (doImport < 0):
            xbmc.log(
                "RCB widget: Error occured while checking db structure: {0}" %
                errorMsg)

        return gdb
    def test_GetGamesByFilter(self):
        db_path = 'C:\\Users\\lom\\AppData\\Roaming\\Kodi\\userdata\\addon_data\\script.games.rom.collection.browser\\'
        gdb = GameDataBase(db_path)
        gdb.connect()
        gdb.checkDBStructure()
        gdb.cursor.execute("PRAGMA cache_size = 20000")

        import time
        timestamp1 = time.process_time()
        games = GameView(gdb).getFilteredGames(0, 0, 0, 0, 0, 0, 0, 0, 0,
                                               '0 = 0', '', 0)
        #games = Game(gdb).getAll()
        timestamp2 = time.process_time()
        diff = (timestamp2 - timestamp1) * 1000
        print("load %d games from db in %d ms" % (len(games), diff))

        timestamp1 = time.process_time()
        #Game(gdb).getGameById(5000)
        row = GameView(gdb).getGameById(5000)
        timestamp2 = time.process_time()
        diff = (timestamp2 - timestamp1) * 1000
        print("load 1 game from db in %d ms" % diff)
Пример #13
0
	def gatherWidgetData(self, param):
		print 'start gatherWidgetData'
		import util, helper
		from gamedatabase import Game, GameDataBase, File
		from config import Config, RomCollection
		
		gdb = GameDataBase(util.getAddonDataPath())
		gdb.connect()
		
		doImport, errorMsg = gdb.checkDBStructure()
		if(doImport) > 0:
			print "RCB: No database available. Won't gather any data."
			gdb.close()
			return
				
		#cache lookup tables
		yearDict = helper.cacheYears(gdb)
		publisherDict = helper.cachePublishers(gdb)
		developerDict = helper.cacheDevelopers(gdb)
		reviewerDict = helper.cacheReviewers(gdb)
		genreDict = helper.cacheGenres(gdb)
				
		limit = int(param.replace('limit=', ''))
		games = Game(gdb).getMostPlayedGames(limit)
		print 'most played games: %s' %games
		
		config = Config(None)
		statusOk, errorMsg = config.readXml()
		
		settings = util.getSettings()
		
		import xbmcgui
		count = 0
		for gameRow in games:
		
			count += 1
			try:
				print "Gathering data for rom no %i: %s" %(count, gameRow[util.ROW_NAME])
				
				romCollection = config.romCollections[str(gameRow[util.GAME_romCollectionId])]				
		
				#get artwork that is chosen to be shown in gamelist
				files = File(gdb).getFilesByParentIds(gameRow[util.ROW_ID], gameRow[util.GAME_romCollectionId], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId])
				fileDict = helper.cacheFiles(files)
				files = helper.getFilesByControl_Cached(gdb, romCollection.imagePlacingMain.fileTypesForGameList, gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict)		
				if(files != None and len(files) != 0):
					thumb = files[0]
				else:
					thumb = ""
					
				files = helper.getFilesByControl_Cached(gdb, romCollection.imagePlacingMain.fileTypesForMainViewBackground, gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict)		
				if(files != None and len(files) != 0):
					fanart = files[0]
				else:
					fanart = ""
				
				description = gameRow[util.GAME_description]
				if(description == None):
					description = ""
				
				year = helper.getPropertyFromCache(gameRow, yearDict, util.GAME_yearId, util.ROW_NAME)
				publisher = helper.getPropertyFromCache(gameRow, publisherDict, util.GAME_publisherId, util.ROW_NAME)
				developer = helper.getPropertyFromCache(gameRow, developerDict, util.GAME_developerId, util.ROW_NAME)
				genre = genreDict[gameRow[util.ROW_ID]]
				
				maxplayers = helper.saveReadString(gameRow[util.GAME_maxPlayers])
				rating = helper.saveReadString(gameRow[util.GAME_rating])
				votes = helper.saveReadString(gameRow[util.GAME_numVotes])
				url = helper.saveReadString(gameRow[util.GAME_url])
				region = helper.saveReadString(gameRow[util.GAME_region])
				media = helper.saveReadString(gameRow[util.GAME_media])				
				perspective = helper.saveReadString(gameRow[util.GAME_perspective])
				controllertype = helper.saveReadString(gameRow[util.GAME_controllerType])
				originaltitle = helper.saveReadString(gameRow[util.GAME_originalTitle])
				alternatetitle = helper.saveReadString(gameRow[util.GAME_alternateTitle])
				translatedby = helper.saveReadString(gameRow[util.GAME_translatedBy])
				version = helper.saveReadString(gameRow[util.GAME_version])
				playcount = helper.saveReadString(gameRow[util.GAME_launchCount])
				
				#get launch command
				filenameRows = File(gdb).getRomsByGameId(gameRow[util.ROW_ID])
				
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Id" %count, str(gameRow[util.ROW_ID]))
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Console" %count, romCollection.name)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Title" %count, gameRow[util.ROW_NAME])
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Thumb" %count, thumb)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Fanart" %count, fanart)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Plot" %count, description)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Year" %count, year)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Publisher" %count, publisher)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Developer" %count, developer)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Genre" %count, genre)
				
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Maxplayers" %count, maxplayers)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Region" %count, region)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Media" %count, media)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Perspective" %count, perspective)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Controllertype" %count, controllertype)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Playcount" %count, playcount)				
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Rating" %count, rating)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Votes" %count, votes)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Url" %count, url)				
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Originaltitle" %count, originaltitle)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Alternatetitle" %count, alternatetitle)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Translatedby" %count, translatedby)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Version" %count, version)
								
			except Exception, (exc):
				print 'RCB: Error while getting most played games: ' +str(exc)
Пример #14
0
    def gatherWidgetData(self, param):
        xbmc.log('start gatherWidgetData')
        import util, helper
        from gamedatabase import Game, GameDataBase, File
        from config import Config

        gdb = GameDataBase(util.getAddonDataPath())
        gdb.connect()

        doImport, errorMsg = gdb.checkDBStructure()
        if (doImport) > 0:
            xbmc.log("RCB: No database available. Won't gather any data.")
            gdb.close()
            return
        elif (doImport < 0):
            xbmc.log("RCB: Error occured while checking db structure: {0}" %
                     errorMsg)

        limit = param.replace('limit=', '')
        query = 'Select * From GameView Where launchCount > 0 Order by launchCount desc Limit %s;' % str(
            limit)
        games = Game(gdb).getGamesByQueryNoArgs(query)
        xbmc.log('most played games: %s' % games)

        config = Config(None)
        statusOk, errorMsg = config.readXml()

        if (not statusOk):
            xbmc.log('RCB: Error reading config.xml: {0}' % errorMsg)
            return

        mediaDict = {}
        mediaDict = helper.cacheMediaPathsForSelection(0, mediaDict, config)

        import xbmcgui
        count = 0
        for game in games:

            count += 1
            try:
                xbmc.log("RCB widget: Gathering data for rom no %i: %s" %
                         (count, game.name))

                romCollection = config.romCollections[str(
                    game.romCollectionId)]
                gamenameFromFile = romCollection.getGamenameFromFilename(
                    game.firstRom)
                mediaPathsDict = mediaDict[str(game.romCollectionId)]

                #get artwork that is chosen to be shown in gamelist
                thumb = helper.getFileForControl(
                    romCollection.imagePlacingMain.fileTypesForGameList,
                    romCollection, mediaPathsDict, gamenameFromFile, False)
                fanart = helper.getFileForControl(
                    romCollection.imagePlacingMain.
                    fileTypesForMainViewBackground, romCollection,
                    mediaPathsDict, gamenameFromFile, False)

                url = "plugin://script.games.rom.collection.browser/?launchid=%s" % game.id

                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Id" % count, str(game.id))
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Console" % count, romCollection.name)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Title" % count, game.name)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Thumb" % count, thumb)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Fanart" % count, fanart)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Plot" % count, game.plot)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Year" % count, game.year)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Publisher" % count, game.publisher)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Developer" % count, game.developer)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Genre" % count, game.genre)

                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Maxplayers" % count, game.maxplayers)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Region" % count, game.region)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Media" % count, game.media)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Perspective" % count, game.perspective)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Controllertype" % count,
                    game.controllertype)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Playcount" % count, game.playcount)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Rating" % count, game.rating)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Votes" % count, game.votes)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Url" % count, url)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Originaltitle" % count,
                    game.originalTitle)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Alternatetitle" % count,
                    game.alternateTitle)
                xbmcgui.Window(10000).setProperty(
                    "MostPlayedROM.%d.Version" % count, game.version)

            except Exception, (exc):
                xbmc.log('RCB: Error while getting most played games: ' +
                         str(exc))
Пример #15
0
    def test_exportLibrary(self):

        export_base_folder = './testdata/nfo/export/'
        xbmcaddon._settings['rcb_nfoFolder'] = export_base_folder

        # Setup data - MyGames.db is the hard-coded expected DB name
        db_path = './testdata/database/'
        shutil.copyfile(os.path.join(db_path, 'MyGames_current_12_games.db'),
                        os.path.join(db_path, 'MyGames.db'))
        gdb = GameDataBase(db_path)
        gdb.connect()

        # Setup config
        config_xml_file = './testdata/config/romcollections_importtests.xml'
        conf = Config(config_xml_file)
        conf.readXml()

        writer = NfoWriter()
        writer.exportLibrary(gdb, conf.romCollections)

        #check if all files have been created
        self.assertTrue(
            os.path.isfile(
                os.path.join(export_base_folder, 'Amiga/Airborne Ranger.nfo')))
        self.assertTrue(
            os.path.isfile(
                os.path.join(export_base_folder, 'Amiga/Chuck Rock.nfo')))
        self.assertTrue(
            os.path.isfile(
                os.path.join(export_base_folder, 'Amiga/Eliminator.nfo')))
        self.assertTrue(
            os.path.isfile(
                os.path.join(export_base_folder,
                             'Amiga/MicroProse Formula One Grand Prix.nfo')))
        self.assertTrue(
            os.path.isfile(
                os.path.join(export_base_folder,
                             'Atari 2600/Adventure (1980) (Atari).nfo')))
        self.assertTrue(
            os.path.isfile(
                os.path.join(
                    export_base_folder,
                    'Atari 2600/Air-Sea Battle (32 in 1) (1988) (Atari) (PAL).nfo'
                )))
        self.assertTrue(
            os.path.isfile(
                os.path.join(
                    export_base_folder,
                    'Atari 2600/Asteroids (1981) (Atari) [no copyright].nfo')))
        #FIXME TODO: can't find file even if it exists
        #self.assertTrue(os.path.isfile(os.path.join(export_base_folder, 'Nintendo 64/1080° Snowboarding.nfo')))
        self.assertTrue(
            os.path.isfile(
                os.path.join(export_base_folder,
                             'PlayStation/Bushido Blade.nfo')))
        self.assertTrue(
            os.path.isfile(
                os.path.join(export_base_folder,
                             'PlayStation/Silent Hill.nfo')))
        self.assertTrue(
            os.path.isfile(
                os.path.join(export_base_folder, 'SNES/Chrono Trigger.nfo')))
        self.assertTrue(
            os.path.isfile(
                os.path.join(export_base_folder, "SNES/Madden NFL '97.nfo")))

        os.remove(os.path.join(export_base_folder,
                               'Amiga/Airborne Ranger.nfo'))
        os.remove(os.path.join(export_base_folder, 'Amiga/Chuck Rock.nfo'))
        os.remove(os.path.join(export_base_folder, 'Amiga/Eliminator.nfo'))
        os.remove(
            os.path.join(export_base_folder,
                         'Amiga/MicroProse Formula One Grand Prix.nfo'))
        os.remove(
            os.path.join(export_base_folder,
                         'Atari 2600/Adventure (1980) (Atari).nfo'))
        os.remove(
            os.path.join(
                export_base_folder,
                'Atari 2600/Air-Sea Battle (32 in 1) (1988) (Atari) (PAL).nfo')
        )
        os.remove(
            os.path.join(
                export_base_folder,
                'Atari 2600/Asteroids (1981) (Atari) [no copyright].nfo'))
        #FIXME TODO: can't find file even if it exists
        #os.remove(os.path.join(export_base_folder, 'Nintendo 64/1080° Snowboarding.nfo'))
        os.remove(
            os.path.join(export_base_folder, 'PlayStation/Bushido Blade.nfo'))
        os.remove(
            os.path.join(export_base_folder, 'PlayStation/Silent Hill.nfo'))
        os.remove(os.path.join(export_base_folder, 'SNES/Chrono Trigger.nfo'))
        os.remove(os.path.join(export_base_folder, "SNES/Madden NFL '97.nfo"))

        gdb.close()
        os.remove(os.path.join(db_path, 'MyGames.db'))
Пример #16
0
    def gatherWidgetData(self, param):
        xbmc.log('start gatherWidgetData')
        import util, helper
        from gamedatabase import DataBaseObject, GameView, GameDataBase
        from config import Config

        gdb = GameDataBase(util.getAddonDataPath())
        gdb.connect()

        doImport, errorMsg = gdb.checkDBStructure()
        if (doImport) > 0:
            xbmc.log("RCB: No database available. Won't gather any data.")
            gdb.close()
            return
        elif (doImport < 0):
            xbmc.log("RCB: Error occured while checking db structure: {0}" % errorMsg)

        limit = param.replace('limit=', '')
        query = 'Select * From GameView Where launchCount > 0 Order by launchCount desc Limit %s;' % str(limit)
        games = GameView(gdb).getGamesByQueryNoArgs(query)
        xbmc.log('most played games: %s' % games)

        config = Config(None)
        statusOk, errorMsg = config.readXml()

        if (not statusOk):
            xbmc.log('RCB: Error reading config.xml: {0}' % errorMsg)
            return

        import xbmcgui
        count = 0
        for game in games:

            count += 1
            try:
                xbmc.log("RCB widget: Gathering data for rom no %i: %s" % (count, game[GameView.COL_NAME]))

                romCollection = config.romCollections[str(game[GameView.COL_romCollectionId])]

                #get artwork that is chosen to be shown in gamelist
                thumb = helper.get_file_for_control_from_db(
                    romCollection.imagePlacingMain.fileTypesForGameList, game)
                fanart = helper.get_file_for_control_from_db(
                    romCollection.imagePlacingMain.fileTypesForMainViewBackground, game)

                url = "plugin://script.games.rom.collection.browser/?launchid=%s" % game[GameView.COL_ID]

                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Id" % count, str(game[GameView.COL_ID]))
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Console" % count, romCollection.name)
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Title" % count, game[GameView.COL_NAME])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Thumb" % count, thumb)
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Fanart" % count, fanart)
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Plot" % count, game[GameView.COL_description])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Year" % count, game[GameView.COL_year])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Publisher" % count, game[GameView.COL_publisher])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Developer" % count, game[GameView.COL_developer])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Genre" % count, game[GameView.COL_genre])

                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Maxplayers" % count, game[GameView.COL_maxPlayers])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Region" % count, game[GameView.COL_region])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Media" % count, game[GameView.COL_description])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Perspective" % count, game[GameView.COL_perspective])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Controllertype" % count, game[GameView.COL_controllerType])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Playcount" % count, game[GameView.COL_launchCount])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Rating" % count, game[GameView.COL_rating])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Votes" % count, game[GameView.COL_numVotes])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Url" % count, game[GameView.COL_url])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Originaltitle" % count, game[GameView.COL_originalTitle])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Alternatetitle" % count, game[GameView.COL_alternateTitle])
                xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Version" % count, game[GameView.COL_version])

            except Exception as exc:
                xbmc.log('RCB: Error while getting most played games: ' + str(exc))

        gdb.close()
Пример #17
0
	def gatherWidgetData(self, param):
		xbmc.log('start gatherWidgetData')
		import util, helper
		from gamedatabase import Game, GameDataBase, File
		from config import Config

		gdb = GameDataBase(util.getAddonDataPath())
		gdb.connect()

		doImport, errorMsg = gdb.checkDBStructure()
		if(doImport) > 0:
			xbmc.log("RCB: No database available. Won't gather any data.")
			gdb.close()
			return
		elif(doImport < 0):
			xbmc.log("RCB: Error occured while checking db structure: {0}" % errorMsg)

		limit = param.replace('limit=', '')
		query = 'Select * From GameView Where launchCount > 0 Order by launchCount desc Limit %s;' %str(limit)
		games = Game(gdb).getGamesByQueryNoArgs(query)
		xbmc.log('most played games: %s' % games)

		config = Config(None)
		statusOk, errorMsg = config.readXml()

		if(not statusOk):
			xbmc.log('RCB: Error reading config.xml: {0}' % errorMsg)
			return

		mediaDict = {}
		mediaDict = helper.cacheMediaPathsForSelection(0, mediaDict, config)

		import xbmcgui
		count = 0
		for game in games:

			count += 1
			try:
				xbmc.log("RCB widget: Gathering data for rom no %i: %s" % (count, game.name))

				romCollection = config.romCollections[str(game.romCollectionId)]
				gamenameFromFile = romCollection.getGamenameFromFilename(game.firstRom)
				mediaPathsDict = mediaDict[str(game.romCollectionId)]

				#get artwork that is chosen to be shown in gamelist
				thumb = helper.getFileForControl(romCollection.imagePlacingMain.fileTypesForGameList, romCollection, mediaPathsDict, gamenameFromFile, False)
				fanart = helper.getFileForControl(romCollection.imagePlacingMain.fileTypesForMainViewBackground, romCollection, mediaPathsDict, gamenameFromFile, False)

				url = "plugin://script.games.rom.collection.browser/?launchid=%s" % game.id

				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Id" % count, str(game.id))
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Console" % count, romCollection.name)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Title" % count, game.name)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Thumb" % count, thumb)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Fanart" % count, fanart)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Plot" % count, game.plot)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Year" % count, game.year)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Publisher" % count, game.publisher)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Developer" % count, game.developer)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Genre" % count, game.genre)

				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Maxplayers" % count, game.maxplayers)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Region" % count, game.region)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Media" % count, game.media)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Perspective" % count, game.perspective)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Controllertype" % count, game.controllertype)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Playcount" % count, game.playcount)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Rating" % count, game.rating)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Votes" % count, game.votes)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Url" % count, url)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Originaltitle" % count, game.originalTitle)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Alternatetitle" % count, game.alternateTitle)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Version" % count, game.version)

			except Exception, (exc):
				xbmc.log('RCB: Error while getting most played games: ' + str(exc))