def get_emulator(self, emulator_name, out_path): cidr = os.getcwd() os.chdir("tmp") emu_file_obj = gd_ops.get_file_meta( self.dsvc, "fullText contains 'EmuCloud_Emulator' and fullText contains '%s' and fullText contains '%s'" % (emulator_name, os.name)) if (emu_file_obj == []): os.chdir(cidr) return None #Hack - only get the first one emu_file_obj = emu_file_obj[0] gd_ops.download_file(self.dsvc, emu_file_obj) #Unzip file to directory. fh = open(emu_file_obj['title'], 'rb') z = zipfile.ZipFile(fh) for name in z.namelist(): z.extract(name, out_path) fh.close() os.remove(emu_file_obj['title']) os.chdir(cidr) self.refresh_emulator_database()
def find_rom(self, system, game_name, extensions): cgame = self.emucloud_db[system][game_name] rom_files = [] for ex in extensions: tp = os.path.join("data", system, "%s.%s" % (game_name, ex)) if (os.path.exists(tp)): self.cloud_rom = False print("Local File Found at %s" % tp) return [tp] #If we can't find it locally, time to hit the cloud. cidr = os.getcwd() #We'll put the game in the tmp directory if we aren't keeping it. if (self.d_after == True): os.chdir("tmp") if (not os.path.exists(os.path.join("data", system))): os.makedirs(os.path.join("data", system)) os.chdir(os.path.join("data", system)) for fid in cgame["file_id"]: rom_file_obj = gd_ops.get_file_by_id(self.dsvc, fid) if (rom_file_obj == None): return None gd_ops.download_file(self.dsvc, rom_file_obj) out_path = "" if (self.d_after == True): out_path = os.path.join("tmp", "data", system, "%s" % (rom_file_obj['title'])) print(out_path) else: out_path = os.path.join("data", system, "%s" % (rom_file_obj['title'])) print(out_path) rom_files.append(out_path) os.chdir(cidr) self.cloud_rom = True return rom_files
def find_rom(self,system,game_name,extensions): cgame = self.emucloud_db[system][game_name] rom_files = [] for ex in extensions: tp = os.path.join("data",system,"%s.%s" % (game_name,ex)) if(os.path.exists(tp)): self.cloud_rom = False print("Local File Found at %s" % tp) return [tp] #If we can't find it locally, time to hit the cloud. cidr = os.getcwd() #We'll put the game in the tmp directory if we aren't keeping it. if(self.d_after == True): os.chdir("tmp") if(not os.path.exists(os.path.join("data",system))): os.makedirs(os.path.join("data",system)) os.chdir(os.path.join("data",system)) for fid in cgame["file_id"]: rom_file_obj = gd_ops.get_file_by_id(self.dsvc,fid) if(rom_file_obj == None): return None gd_ops.download_file(self.dsvc,rom_file_obj) out_path = "" if(self.d_after == True): out_path = os.path.join("tmp","data",system,"%s" % (rom_file_obj['title'])) print(out_path) else: out_path = os.path.join("data",system,"%s" % (rom_file_obj['title'])) print(out_path) rom_files.append(out_path) os.chdir(cidr) self.cloud_rom = True return rom_files
def get_emulator(self,emulator_name,out_path): cidr = os.getcwd() os.chdir("tmp") emu_file_obj = gd_ops.get_file_meta(self.dsvc,"fullText contains 'EmuCloud_Emulator' and fullText contains '%s' and fullText contains '%s'" % ( emulator_name,os.name)) if(emu_file_obj == []): os.chdir(cidr) return None #Hack - only get the first one emu_file_obj = emu_file_obj[0] gd_ops.download_file(self.dsvc,emu_file_obj) #Unzip file to directory. fh = open(emu_file_obj['title'], 'rb') z = zipfile.ZipFile(fh) for name in z.namelist(): z.extract(name,out_path) fh.close() os.remove(emu_file_obj['title']) os.chdir(cidr) self.refresh_emulator_database()