Beispiel #1
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])
Beispiel #2
0
def proc_rom(dsvc,parent_id,inpath):
	upload_list = []
	base,romfile = os.path.split(inpath)
	base_romname,ext = os.path.splitext(romfile)
	if(ext.startswith(".")):
		ext = ext[1:]
	if(ext not in SUPPORTED_EXTENSIONS):
		return
	print("Processing: %s " % inpath)
	if(base_romname in ROM_DB):
		game_info = ROM_DB[base_romname]
	else:
		game_info = {}
		game_info['game_system'] = system_name
		game_info['game_name'] = base_romname
		game_info['emulator'] = EMULATOR
		game_info['players'] = ""
		game_info['cloneof'] = ""
		game_info['year'] = ""
		game_info['manufacturer'] = ""
		game_info['genre'] = ""
		game_info['game_region'] = ""
		game_info['rating'] = ""
		game_info['enabled'] = "Yes"
	#Get hash.
	game_info['sha1'] = get_sha1sum(inpath)
	desc = gen_description("EmuCloud_Entry",game_info)
	#Add rom to our upload list.
	upload_list.append([inpath,desc])
	
	#Add icon to our upload list.
	for root,dirs,files in os.walk("icon"):
		for f in files:
			if f.startswith(base_romname):
				print("Found Icon %s" % os.path.join(root,f))
				rt,parent = os.path.split(root)
				basef,ext = os.path.splitext(f)
				if(not basef.endswith("_%s" % parent)):
					fixed_name = os.path.join(root,"%s_%s%s" % (basef,parent,ext))
					os.rename(os.path.join(root,f),fixed_name)
				else:
					fixed_name = os.path.join(root,f)
				upload_list.append([fixed_name,"EmuCloud_Icon <game_system>%s</game_system><game_name>%s</game_name>" % (system_name,base_romname)])
	
	#Add any artwork to our upload list.
	for root,dirs,files in os.walk("artwork"):
		for f in files:
			if f.startswith(base_romname):
				print("Found Artwork %s" % os.path.join(root,f))
				rt,parent = os.path.split(root)
				basef,ext = os.path.splitext(f)
				if(not basef.endswith("_%s" % parent)):
					fixed_name = os.path.join(root,"%s_%s%s" % (basef,parent,ext))
					os.rename(os.path.join(root,f),fixed_name)
				else:
					fixed_name = os.path.join(root,f)
				upload_list.append([fixed_name,"EmuCloud_Artwork <game_system>%s</game_system><game_name>%s</game_name>" % (system_name,base_romname)])
	

	
	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' and fullText contains '%s'" % (name.replace("'","\\'"),system_name,base_romname.replace("'","\\'")))
		
		if(emu_file_obj != []):
			print("Skipping %s" % name)
			continue
			
		print("Uploading %s" % name)
		gd_ops.upload_file(dsvc, name, item[1], parent_id, "", item[0])
Beispiel #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])
Beispiel #4
0
def proc_rom(dsvc, parent_id, inpath):
    upload_list = []
    base, romfile = os.path.split(inpath)
    base_romname, ext = os.path.splitext(romfile)
    if (ext.startswith(".")):
        ext = ext[1:]
    if (ext not in SUPPORTED_EXTENSIONS):
        return
    print("Processing: %s " % inpath)
    if (base_romname in ROM_DB):
        game_info = ROM_DB[base_romname]
    else:
        game_info = {}
        game_info['game_system'] = system_name
        game_info['game_name'] = base_romname
        game_info['emulator'] = EMULATOR
        game_info['players'] = ""
        game_info['cloneof'] = ""
        game_info['year'] = ""
        game_info['manufacturer'] = ""
        game_info['genre'] = ""
        game_info['game_region'] = ""
        game_info['rating'] = ""
        game_info['enabled'] = "Yes"
    #Get hash.
    game_info['sha1'] = get_sha1sum(inpath)
    desc = gen_description("EmuCloud_Entry", game_info)
    #Add rom to our upload list.
    upload_list.append([inpath, desc])

    #Add icon to our upload list.
    for root, dirs, files in os.walk("icon"):
        for f in files:
            if f.startswith(base_romname):
                print("Found Icon %s" % os.path.join(root, f))
                rt, parent = os.path.split(root)
                basef, ext = os.path.splitext(f)
                if (not basef.endswith("_%s" % parent)):
                    fixed_name = os.path.join(root,
                                              "%s_%s%s" % (basef, parent, ext))
                    os.rename(os.path.join(root, f), fixed_name)
                else:
                    fixed_name = os.path.join(root, f)
                upload_list.append([
                    fixed_name,
                    "EmuCloud_Icon <game_system>%s</game_system><game_name>%s</game_name>"
                    % (system_name, base_romname)
                ])

    #Add any artwork to our upload list.
    for root, dirs, files in os.walk("artwork"):
        for f in files:
            if f.startswith(base_romname):
                print("Found Artwork %s" % os.path.join(root, f))
                rt, parent = os.path.split(root)
                basef, ext = os.path.splitext(f)
                if (not basef.endswith("_%s" % parent)):
                    fixed_name = os.path.join(root,
                                              "%s_%s%s" % (basef, parent, ext))
                    os.rename(os.path.join(root, f), fixed_name)
                else:
                    fixed_name = os.path.join(root, f)
                upload_list.append([
                    fixed_name,
                    "EmuCloud_Artwork <game_system>%s</game_system><game_name>%s</game_name>"
                    % (system_name, base_romname)
                ])

    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' and fullText contains '%s'"
            % (name.replace(
                "'", "\\'"), system_name, base_romname.replace("'", "\\'")))

        if (emu_file_obj != []):
            print("Skipping %s" % name)
            continue

        print("Uploading %s" % name)
        gd_ops.upload_file(dsvc, name, item[1], parent_id, "", item[0])