예제 #1
0
def copyLauncherScriptsToUserdata(settings):

    Logutil.log('copyLauncherScriptsToUserdata', util.LOG_LEVEL_INFO)

    oldBasePath = os.path.join(util.getAddonInstallPath(), 'resources',
                               'scriptfiles')
    newBasePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')

    if (util.getEnvironment() == 'win32'):
        oldPath = os.path.join(oldBasePath, 'applaunch.bat')
        newPath = os.path.join(newBasePath, 'applaunch.bat')
    else:
        oldPath = os.path.join(oldBasePath, 'applaunch.sh')
        newPath = os.path.join(newBasePath, 'applaunch.sh')

    util.copyFile(oldPath, newPath)

    #copy VBS files
    if (util.getEnvironment() == 'win32' and settings.getSetting(
            util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true'):
        oldPath = os.path.join(oldBasePath, 'applaunch-vbs.bat')
        newPath = os.path.join(newBasePath, 'applaunch-vbs.bat')
        util.copyFile(oldPath, newPath)

        oldPath = os.path.join(oldBasePath, 'LaunchXBMC.vbs')
        newPath = os.path.join(newBasePath, 'LaunchXBMC.vbs')
        util.copyFile(oldPath, newPath)

        oldPath = os.path.join(oldBasePath, 'Sleep.vbs')
        newPath = os.path.join(newBasePath, 'Sleep.vbs')
        util.copyFile(oldPath, newPath)
def copyLauncherScriptsToUserdata(settings):
	
	Logutil.log('copyLauncherScriptsToUserdata', util.LOG_LEVEL_INFO)
	
	oldBasePath = os.path.join(util.getAddonInstallPath(), 'resources', 'scriptfiles')
	newBasePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')
	
	if(util.getEnvironment() == 'win32'):
		oldPath = os.path.join(oldBasePath, 'applaunch.bat')
		newPath = os.path.join(newBasePath, 'applaunch.bat')
	else:
		oldPath = os.path.join(oldBasePath, 'applaunch.sh')
		newPath = os.path.join(newBasePath, 'applaunch.sh')
		
	util.copyFile(oldPath, newPath)
	
	#copy VBS files
	if(util.getEnvironment() == 'win32' and settings.getSetting(util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true'):
		oldPath = os.path.join(oldBasePath, 'applaunch-vbs.bat')
		newPath = os.path.join(newBasePath, 'applaunch-vbs.bat')
		util.copyFile(oldPath, newPath)
		
		oldPath = os.path.join(oldBasePath, 'LaunchXBMC.vbs')
		newPath = os.path.join(newBasePath, 'LaunchXBMC.vbs')
		util.copyFile(oldPath, newPath)
		
		oldPath = os.path.join(oldBasePath, 'Sleep.vbs')
		newPath = os.path.join(newBasePath, 'Sleep.vbs')
		util.copyFile(oldPath, newPath)
def writeAutoexec(gdb):
	# Backup original autoexec.py		
	autoexec = util.getAutoexecPath()
	backupAutoexec(gdb, autoexec)

	# Write new autoexec.py
	try:
		path = os.path.join(util.RCBHOME, 'default.py')
		if(util.getEnvironment() == 'win32'):
			#HACK: There is an error with "\a" in autoexec.py on windows, so we need "\A"
			path = path.replace('\\addons', '\\Addons')
			
		fh = open(autoexec,'w') # truncate to 0
		fh.write("#Rom Collection Browser autoexec\n")
		fh.write("import xbmc\n")
		fh.write("xbmc.executescript('"+ path+"')\n")
		fh.close()
	except Exception, (exc):
		Logutil.log("Cannot write to autoexec.py: " +str(exc), util.LOG_LEVEL_ERROR)
		return
예제 #4
0
파일: launcher.py 프로젝트: roeiba/xbmc
def writeAutoexec(gdb):
	# Backup original autoexec.py		
	autoexec = util.getAutoexecPath()
	backupAutoexec(gdb, autoexec)

	# Write new autoexec.py
	try:
		path = os.path.join(util.RCBHOME, 'default.py')
		if(util.getEnvironment() == 'win32'):
			#HACK: There is an error with "\a" in autoexec.py on windows, so we need "\A"
			path = path.replace('\\addons', '\\Addons')
			
		fh = open(autoexec,'w') # truncate to 0
		fh.write("#Rom Collection Browser autoexec\n")
		fh.write("import xbmc\n")
		fh.write("xbmc.executescript('"+ path+"')\n")
		fh.close()
	except Exception, (exc):
		Logutil.log("Cannot write to autoexec.py: " +str(exc), util.LOG_LEVEL_ERROR)
		return
예제 #5
0
def launchEmu(gdb, gui, gameId, config, settings, listitem):
    Logutil.log("Begin launcher.launchEmu", util.LOG_LEVEL_INFO)

    gameRow = Game(gdb).getObjectById(gameId)
    if (gameRow == None):
        Logutil.log("Game with id %s could not be found in database" % gameId,
                    util.LOG_LEVEL_ERROR)
        return

    romCollection = None
    try:
        romCollection = config.romCollections[str(
            gameRow[util.GAME_romCollectionId])]
    except:
        Logutil.log(
            'Cannot get rom collection with id: ' +
            str(gameRow[util.GAME_romCollectionId]), util.LOG_LEVEL_ERROR)
        gui.writeMsg(util.localize(32034))
        return

    gui.writeMsg(util.localize(32163) + " " + gameRow[util.ROW_NAME])

    # Remember viewstate
    gui.saveViewState(False)

    cmd = ""
    precmd = ""
    postcmd = ""

    #get environment OS
    env = util.getEnvironment()

    filenameRows = File(gdb).getRomsByGameId(gameRow[util.ROW_ID])
    Logutil.log("files for current game: " + str(filenameRows),
                util.LOG_LEVEL_INFO)

    escapeCmd = settings.getSetting(
        util.SETTING_RCB_ESCAPECOMMAND).upper() == 'TRUE'
    cmd, precmd, postcmd, roms = buildCmd(filenameRows, romCollection, gameRow,
                                          escapeCmd, False)

    if (not romCollection.useBuiltinEmulator):
        if (cmd == ''):
            Logutil.log('No cmd created. Game will not be launched.',
                        util.LOG_LEVEL_INFO)
            return
        if (precmd.strip() == '' or precmd.strip() == 'call'):
            Logutil.log('No precmd created.', util.LOG_LEVEL_INFO)

        if (postcmd.strip() == '' or postcmd.strip() == 'call'):
            Logutil.log('No postcmd created.', util.LOG_LEVEL_INFO)

        #solo mode
        if (romCollection.useEmuSolo):

            copyLauncherScriptsToUserdata(settings)

            #check if we should use xbmc.service (Eden) or autoexec.py (Dharma)
            if (not gui.useRCBService):
                #try to create autoexec.py
                writeAutoexec(gdb)
            else:
                #communicate with service via settings
                settings.setSetting(util.SETTING_RCB_LAUNCHONSTARTUP, 'true')

            #invoke script file that kills xbmc before launching the emulator
            basePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')
            #xbmc needs other script files than kodi
            xbmcFilenameSuffix = "_xbmc"
            if KodiVersions().getKodiVersion() >= KodiVersions.HELIX:
                xbmcFilenameSuffix = ""

            if (env == "win32"):
                if (settings.getSetting(
                        util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true'):
                    #There is a problem with quotes passed as argument to windows command shell. This only works with "call"
                    #use vb script to restart xbmc
                    cmd = 'call \"' + os.path.join(
                        basePath, 'applaunch-vbs%s.bat' %
                        xbmcFilenameSuffix) + '\" ' + cmd
                else:
                    #There is a problem with quotes passed as argument to windows command shell. This only works with "call"
                    cmd = 'call \"' + os.path.join(
                        basePath,
                        'applaunch%s.bat' % xbmcFilenameSuffix) + '\" ' + cmd
            else:
                cmd = os.path.join(
                    basePath, 'applaunch%s.sh ' % xbmcFilenameSuffix) + cmd
        else:
            #use call to support paths with whitespaces
            if (env == "win32"
                    and not (os.environ.get("OS", "xbox") == "xbox")):
                cmd = 'call ' + cmd

    #update LaunchCount
    launchCount = gameRow[util.GAME_launchCount]
    Game(gdb).update(('launchCount', ), (launchCount + 1, ),
                     gameRow[util.ROW_ID], True)
    gdb.commit()

    Logutil.log("cmd: " + cmd, util.LOG_LEVEL_INFO)
    Logutil.log("precmd: " + precmd, util.LOG_LEVEL_INFO)
    Logutil.log("postcmd: " + postcmd, util.LOG_LEVEL_INFO)

    try:
        if (os.environ.get("OS", "xbox") == "xbox"):
            launchXbox(gui, gdb, cmd, romCollection, filenameRows)
        else:
            launchNonXbox(cmd, romCollection, gameRow, settings, precmd,
                          postcmd, roms, gui, listitem)

        gui.writeMsg("")

    except Exception, (exc):
        Logutil.log("Error while launching emu: " + str(exc),
                    util.LOG_LEVEL_ERROR)
        gui.writeMsg(util.localize(32035) + ": " + str(exc))
def launchEmu(gdb, gui, gameId, config, settings, listitem):
	Logutil.log("Begin launcher.launchEmu", util.LOG_LEVEL_INFO)
	
	gameRow = Game(gdb).getObjectById(gameId)
	if(gameRow == None):
		Logutil.log("Game with id %s could not be found in database" %gameId, util.LOG_LEVEL_ERROR)
		return
		
	romCollection = None
	try:
		romCollection = config.romCollections[str(gameRow[util.GAME_romCollectionId])]
	except:
		Logutil.log('Cannot get rom collection with id: ' +str(gameRow[util.GAME_romCollectionId]), util.LOG_LEVEL_ERROR)
		gui.writeMsg(util.localize(32034))
		return
			
	gui.writeMsg(util.localize(32163)+ " " +gameRow[util.ROW_NAME])
	
	# Remember viewstate
	gui.saveViewState(False)
	
	cmd = ""
	precmd = ""
	postcmd = ""
	
	#get environment OS
	env = util.getEnvironment()
			
	filenameRows = File(gdb).getRomsByGameId(gameRow[util.ROW_ID])
	Logutil.log("files for current game: " +str(filenameRows), util.LOG_LEVEL_INFO)
		
	escapeCmd = settings.getSetting(util.SETTING_RCB_ESCAPECOMMAND).upper() == 'TRUE'
	cmd, precmd, postcmd, roms = buildCmd(filenameRows, romCollection, gameRow, escapeCmd, False)
	
	if (not romCollection.useBuiltinEmulator):
		if(cmd == ''):
			Logutil.log('No cmd created. Game will not be launched.', util.LOG_LEVEL_INFO)
			return
		if(precmd.strip() == '' or precmd.strip() == 'call'):
			Logutil.log('No precmd created.', util.LOG_LEVEL_INFO)
			
		if(postcmd.strip() == '' or postcmd.strip() == 'call'):
			Logutil.log('No postcmd created.', util.LOG_LEVEL_INFO)
			
		#solo mode
		if (romCollection.useEmuSolo):
			
			copyLauncherScriptsToUserdata(settings)
			
			#check if we should use xbmc.service (Eden) or autoexec.py (Dharma)
			if(not gui.useRCBService):
				#try to create autoexec.py
				writeAutoexec(gdb)
			else:
				#communicate with service via settings
				settings.setSetting(util.SETTING_RCB_LAUNCHONSTARTUP, 'true')
			
			#invoke script file that kills xbmc before launching the emulator
			basePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')
			#xbmc needs other script files than kodi
			xbmcFilenameSuffix = "_xbmc"
			if(int(gui.xbmcversionNo) >= util.XBMC_VERSION_HELIX):
				xbmcFilenameSuffix = ""
						
			if(env == "win32"):
				if(settings.getSetting(util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true'):
					#There is a problem with quotes passed as argument to windows command shell. This only works with "call"
					#use vb script to restart xbmc
					cmd = 'call \"' +os.path.join(basePath, 'applaunch-vbs%s.bat' %xbmcFilenameSuffix) +'\" ' +cmd
				else:					
					#There is a problem with quotes passed as argument to windows command shell. This only works with "call"
					cmd = 'call \"' +os.path.join(basePath, 'applaunch%s.bat' %xbmcFilenameSuffix) +'\" ' +cmd						
			else:
				cmd = os.path.join(basePath, 'applaunch%s.sh ' %xbmcFilenameSuffix) +cmd
		else:
			#use call to support paths with whitespaces
			if(env == "win32" and not (os.environ.get( "OS", "xbox" ) == "xbox")):
				cmd = 'call ' +cmd
	
	#update LaunchCount
	launchCount = gameRow[util.GAME_launchCount]
	Game(gdb).update(('launchCount',), (launchCount +1,) , gameRow[util.ROW_ID], True)
	gdb.commit()
	
	Logutil.log("cmd: " +cmd, util.LOG_LEVEL_INFO)	
	Logutil.log("precmd: " +precmd, util.LOG_LEVEL_INFO)
	Logutil.log("postcmd: " +postcmd, util.LOG_LEVEL_INFO)
	
	try:
		if (os.environ.get( "OS", "xbox" ) == "xbox"):			
			launchXbox(gui, gdb, cmd, romCollection, filenameRows)
		else:
			launchNonXbox(cmd, romCollection, gameRow, settings, precmd, postcmd, roms, gui, listitem)
	
		gui.writeMsg("")
					
	except Exception, (exc):
		Logutil.log("Error while launching emu: " +str(exc), util.LOG_LEVEL_ERROR)
		gui.writeMsg(util.localize(32035) +": " +str(exc))