Exemplo n.º 1
0
	def __init__(self,gdsvc=None,emucloud_db=None):
		self.app_root = os.getcwd()
		#Set up environment.
		if(not os.path.exists("emulators")):
			os.makedirs("emulators")
		if(not os.path.exists("data")):
			os.makedirs("data")
		if(not os.path.exists("databases")):
			os.makedirs("databases")
			os.system("python emucloud_dbgen.py")
		
		if(not os.path.exists(os.path.join("emulators","__init__.py"))):
				f = open(os.path.join("emulators","__init__.py"),"wb")
				f.close()
		if(not os.path.exists("tmp")):
			os.makedirs("tmp")
		#End Setting up Environment.
		if(gdsvc == None):
			logging.debug("Logging into GDrive...")
			gdsvc = gd_auth.drive_login()
		if(gdsvc == None):
			logging.critical("Unable to Sign into GDrive!")
			exit(1)
		self.dsvc = gdsvc
		#Find out if we delete the rom afterward - defaults to true, can be set in the web interface.
		self.d_after = True
		#State that monitors if the rom loaded is local or cloud.
		self.cloud_rom = False
		self.emucloud_db = emucloud_db
		if(emucloud_db == None):
			self.refresh_emucloud_database()
		if(self.emucloud_db == None):
			logging.critical("Unable to DB")
			exit(1)
		if(self.emucloud_db == []):
			logging.warning("No entries")
		self.emulator_db = {} 
		self.refresh_emulator_database()
		self.current_system=None
Exemplo n.º 2
0
			game_name = get_field(g,"game_name")
		else:
			continue
		if(not game_system in ROM.keys()):
				ROM[game_system] = {}
				
		if(game_name in ROM[game_system].keys()):
			ROM[game_system][game_name] = append_rom_entry(g,ROM[game_system][game_name])
		else:
			
			ROM[game_system][game_name] = gen_rom_entry(g)

	
		
if(__name__=="__main__"):
	
	#Might as well leave it logged in.
	dsvc = gd_auth.drive_login()
	if(len(sys.argv) > 1):
		#Get metadata of all Emucloud roms.
		refresh_db(dsvc,sys.argv[1])
	else:
		refresh_db(dsvc)
	#Print New XML Files.
	for sys in ROM.keys():
		if(sys == "Unsorted" or sys == []):
			continue
		
		#gen_xml(ROM[sys],sys)
		gen_json(ROM[sys],sys)
		
Exemplo n.º 3
0
def upload_data(system_name, game_info):
    dsvc = gd_auth.drive_login()
    if len(sys.argv) > 3:
        parent_id = sys.argv[3]
    else:
        gd_ops.get_root_id(dsvc)
    upload_list = []

    print("Enumerating Roms...")
    for root, dirs, files in os.walk("roms"):

        for f in files:

            fb, fe = os.path.splitext(f)
            game_id = find_entry(fb, game_info)
            if game_id == None:
                print("Rom for %s not found." % game_info[game_id]["name"])
                continue
            else:
                # Get hash.
                game_info[game_id]["sha1"] = get_sha1sum(os.path.join(root, f))

                # Add rom to our upload list.
                upload_list.append([os.path.join(root, f), "cFE_DATA:%s" % game_id])
                # Add icon to our upload list.
                for root2, dirs2, files2 in os.walk("icon"):
                    for f2 in files2:
                        if f2.startswith(game_info[game_id]["name"]):
                            rt, parent = os.path.split(root2)
                            basef, ext = os.path.splitext(f2)
                            if not basef.endswith("_%s" % parent):
                                fixed_name = os.path.join(root2, "%s_%s%s" % (basef, parent, ext))

                                os.rename(os.path.join(root2, f2), fixed_name)
                            else:
                                fixed_name = os.path.join(root2, f2)
                            upload_list.append([fixed_name, "cFE_ICON:%s" % game_id])
                            break
                            # Add any artwork to our upload list.
                for root3, dirs3, files3 in os.walk("artwork"):
                    for f3 in files3:
                        if f3.startswith(game_info[game_id]["name"]):
                            print("Found Artwork %s" % os.path.join(root3, f3))
                            rt, parent = os.path.split(root3)
                            basef, ext = os.path.splitext(f3)
                            if not basef.endswith("_%s" % parent):
                                fixed_name = os.path.join(root3, "%s_%s%s" % (basef, parent, ext))
                                os.rename(os.path.join(root3, f3), fixed_name)
                            else:
                                fixed_name = os.path.join(root3, f3)

                            upload_list.append([fixed_name, "cFE_ARTW:%s" % game_id])

    up_total = len(upload_list)
    up_counter = 0
    for item in upload_list:
        # Check to make sure we aren't uploading a duplicate.
        baspth, name = os.path.split(item[0])
        emu_file_obj = gd_ops.get_file_meta(
            dsvc, "title='%s' and fullText contains '%s'" % (name.replace("'", "\\'"), item[1])
        )
        up_counter += 1
        if emu_file_obj != []:
            print("[%d/%d] Skipping: %s" % (up_counter, up_total, name))
            continue

        print("[%d/%d] Uploading: %s" % (up_counter, up_total, name))
        gd_ops.upload_file(dsvc, name, item[1], parent_id, "", item[0])