Exemplo n.º 1
0
	def reload_db(self,first_run=False):
		self.cfe_database = {}
		if(first_run == False):
			cfe_dbgen.run()
			self.get_loader_db()
		#Load Any local databases.
		for root,dirs,files in os.walk("databases"):
			for f in files:
				if(f.endswith(".json") and f != "Loaders.json"):
					fb,fe = os.path.splitext(f)
					if(not fb in self.cfe_database.keys()):
						self.cfe_database[fb] = {}
					json_data=open(os.path.join(root,f))
					jd = json.load(json_data)
					json_data.close()
					for j in jd.keys():
						req_emu=""
						if(not 'loader' in jd[j].keys() and os.name in self.loaderdb[jd[j]['system']]):
							req_emu = self.loaderdb[jd[j]['system']][os.name].keys()[0]
						if('loader' in jd[j].keys()):
							req_emu = jd[j]['loader']
						
						
						if(req_emu==""):
							req_emu = self.loaderdb[jd[j]['system']][os.name].keys()[0]
							
						if(os.name in self.loaderdb[fb] and req_emu in self.loaderdb[fb][os.name]):
							jd[j]['has_loader'] = True
							jd[j]['loader'] = req_emu
						else:
							jd[j]['loader'] = ""
							jd[j]['has_loader'] = False
						self.cfe_database[fb][j] = jd[j]		
Exemplo n.º 2
0
    def run(self, req):
        #req = base64.b64decode(req)
        system = self.selected_system
        entry_id = req
        print(system)
        print(entry_id)
        entry = self.cfe_database[system][entry_id]
        #See if we have the emulator already.

        if (not os.path.exists(os.path.join("loaders", entry['loader']))):
            os.makedirs(os.path.join("loaders", entry['loader']))
            out_path = os.path.join(self.app_root, "loaders", entry['loader'])
            #Get the emulator if we can't find it locally.
            os.chdir("tmp")

            fls = self.loaderdb[self.selected_system][os.name][entry['loader']]

            for svc in self.cloud_services.keys():
                file_lst = []
                if (fls['svc'] == svc):
                    for fl in fls['id']:
                        op = self.cloud_services[svc].get_file(fl)
                        if (op != None):
                            file_lst.append(op)
                    break

            os.chdir(self.app_root)
            file_lst = sorted(file_lst)
            for fl in file_lst:
                fh = open(fl, 'rb')
                z = zipfile.ZipFile(fh)
                for name in z.namelist():
                    z.extract(name, out_path)
                fh.close()
                os.remove(fl)

        try:
            ldr = importlib.import_module("loaders.%s" % entry['loader'])
        except:
            return "Error getting emulator module inserted loaders.%s" % entry[
                'loader']
        #Get all the data files.

        data_path = self.find_data_dir(entry_id)

        if (data_path != None):

            ldr.run(data_path)

        else:
            cfe_dbgen.run()
            self.refresh_emucloud_database()
            return "Error - %s Rom not found. Regenerating Database..." % game_name
        #Execute and Cleanup.
        return "<input type='button' name='reset_menu' value='Back to Menu' onclick=\"location.href='reset'\">"
Exemplo n.º 3
0
	def run(self,req):
		#req = base64.b64decode(req)
		system = self.selected_system
		entry_id = req
		print(system)
		print(entry_id)
		entry = self.cfe_database[system][entry_id]
		#See if we have the emulator already.
		
		if(not os.path.exists(os.path.join("loaders",entry['loader']))):
			os.makedirs(os.path.join("loaders",entry['loader']))
			out_path = os.path.join(self.app_root,"loaders",entry['loader'])
			#Get the emulator if we can't find it locally.
			os.chdir("tmp")
			
			fls = self.loaderdb[self.selected_system][os.name][entry['loader']]
			
			for svc in self.cloud_services.keys():
				file_lst = []
				if(fls['svc'] == svc):
					for fl in fls['id']:
						op = self.cloud_services[svc].get_file(fl)
						if(op != None):
							file_lst.append(op)
					break
			
			os.chdir(self.app_root)
			file_lst = sorted(file_lst)
			for fl in file_lst:
				fh = open(fl, 'rb')
				z = zipfile.ZipFile(fh)
				for name in z.namelist():
					z.extract(name,out_path)
				fh.close()
				os.remove(fl)

		try:
			ldr = importlib.import_module("loaders.%s" % entry['loader'])
		except:
			return "Error getting emulator module inserted loaders.%s"% entry['loader']	
		#Get all the data files.
				
		data_path = self.find_data_dir(entry_id)
		
		if(data_path != None):
			
			ldr.run(data_path)
			
		else:
			cfe_dbgen.run()
			self.refresh_emucloud_database()
			return "Error - %s Rom not found. Regenerating Database..." % game_name
		#Execute and Cleanup.
		return "<input type='button' name='reset_menu' value='Back to Menu' onclick=\"location.href='reset'\">"
Exemplo n.º 4
0
    def reload_db(self, first_run=False):
        self.cfe_database = {}
        if (first_run == False):
            cfe_dbgen.run()
            self.get_loader_db()
        #Load Any local databases.
        for root, dirs, files in os.walk("databases"):
            for f in files:
                if (f.endswith(".json") and f != "Loaders.json"):
                    fb, fe = os.path.splitext(f)
                    if (not fb in self.cfe_database.keys()):
                        self.cfe_database[fb] = {}
                    json_data = open(os.path.join(root, f))
                    jd = json.load(json_data)
                    json_data.close()
                    for j in jd.keys():
                        req_emu = ""
                        if (not 'loader' in jd[j].keys()
                                and os.name in self.loaderdb[jd[j]['system']]):
                            req_emu = self.loaderdb[jd[j]['system']][
                                os.name].keys()[0]
                        if ('loader' in jd[j].keys()):
                            req_emu = jd[j]['loader']

                        if (req_emu == ""):
                            req_emu = self.loaderdb[jd[j]['system']][
                                os.name].keys()[0]

                        if (os.name in self.loaderdb[fb]
                                and req_emu in self.loaderdb[fb][os.name]):
                            jd[j]['has_loader'] = True
                            jd[j]['loader'] = req_emu
                        else:
                            jd[j]['loader'] = ""
                            jd[j]['has_loader'] = False
                        self.cfe_database[fb][j] = jd[j]
Exemplo n.º 5
0
 def regen(self):
     cfe_dbgen.run()
     self.get_loader_db()
     self.reload_db(True)
     self.cache_system_list = ""
     raise cherrypy.HTTPRedirect("/")
Exemplo n.º 6
0
	def regen(self):
		cfe_dbgen.run()
		self.get_loader_db()
		self.reload_db(True)
		self.cache_system_list=""
		raise cherrypy.HTTPRedirect("/")