Adding upload_xdelta function to upload patch to google drive

This commit is contained in:
Stewie
2022-04-11 19:02:03 -04:00
parent 63d50555f2
commit 1c96d64ae7
7 changed files with 38 additions and 17 deletions

View File

@@ -26,6 +26,6 @@ def refresh_repo(repo_name):
base_path = os.path.join(os.getcwd(), "..", repo_name)
print("Repo to refresh: {}".format(base_path))
listFile = subprocess.run(
["git", "pull", repo_name],
["git", "pull"],
cwd=base_path
)

View File

@@ -24,14 +24,14 @@ class ToolsTOR(ToolsTales):
#Path to used
datBinOriginal = '../Data/TOR/Disc/Original/DAT.BIN'
datBinNew = '../Data/TOR/Disc/New/DAT.BIN'
elfOriginal = '../Data/TOR/Disc/Original/SLPS_254.50'
elfNew = '../Data/TOR/Disc/New/SLPS_254.50'
datBinOriginal = '../Data/Tales-Of-Rebirth/Disc/Original/DAT.BIN'
datBinNew = '../Data/Tales-Of-Rebirth/Disc/New/DAT.BIN'
elfOriginal = '../Data/Tales-Of-Rebirth/Disc/Original/SLPS_254.50'
elfNew = '../Data/Tales-Of-Rebirth/Disc/New/SLPS_254.50'
storyPathArchives= '../Tales-Of-Rebirth/Data/TOR/Story/New/' #Story XML files will be extracted here
storyPathXML = '../Tales-Of-Rebirth/Data/TOR/Story/XML/' #SCPK will be repacked here
skitPathArchives = '../Tales-Of-Rebirth/Data/TOR/Skits/' #Skits XML files will be extracted here
datPathExtract = '../Data/TOR/DAT/'
datPathExtract = '../Data/Tales-Of-Rebirth/DAT/'
def __init__(self, tbl):

View File

@@ -31,7 +31,7 @@ class ToolsTales:
self.repo_name = repo_name
self.basePath = os.getcwd()
with open("../{}/Data/Misc/{}".format(repo_name, tblFile), encoding="utf-8") as f:
with open("../{}/Data/{}/Misc/{}".format(repo_name, gameName, tblFile), encoding="utf-8") as f:
jsonRaw = json.load(f)
if self.repo_name == "Tales-of-Destiny-DC":
self.jsonTblTags ={ k1:{ int(k2) if (k1 != "TBL") else k2:v2 for k2,v2 in jsonRaw[k1].items()} for k1,v1 in jsonRaw.items()}
@@ -45,7 +45,7 @@ class ToolsTales:
self.icolors = dict([[i, j] for j, i in self.jsonTblTags['COLOR'].items()])
with open("../{}/Data/Menu/MenuFiles.json".format(repo_name)) as f:
with open("../{}/Data/{}/Menu/MenuFiles.json".format(repo_name, gameName)) as f:
self.menu_files_json = json.load(f)
@@ -635,11 +635,12 @@ class ToolsTales:
#
#############################
def insert_Menu_File(self, menu_file_path):
def pack_Menu_File(self, menu_file_path):
#Load all the banks for insertion and load XML
new_text_offsets = dict()
file_node = [ele for ele in self.menu_files_json if ele['File_Extract'] == menu_file_path][0]
xml_file_name = "../{}/Data/{}/Menu/XML/".format(self.repo_name, self.gameName) + self.get_file_name(menu_file_path)+'.xml'
@@ -652,7 +653,7 @@ class ToolsTales:
#Copy the original file
new_file_path = "../Data/TOR/Menu/New/{}".format(os.path.basename(file_node['File_Original']))
new_file_path = "../Data/{}/Menu/New/{}".format(self.repo_name, os.path.basename(file_node['File_Original']))
shutil.copy( file_node['File_Extract'], new_file_path)
#Open the new file with r+b

View File

@@ -9,15 +9,37 @@ import requests
import subprocess
import ApacheAutomate
import RepoFunctions
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
SCRIPT_VERSION = "0.3"
GoogleAuth.DEFAULT_SETTINGS['client_config_file'] = "../client_secrets.json"
def generate_xdelta_patch(original_path, new_path, xdelta_name="Tales-Of-Rebirth_Patch_New.xdelta"):
def generate_xdelta_patch(repo_name, xdelta_name="Tales-Of-Rebirth_Patch_New.xdelta"):
print("Create xdelta patch")
original_path = "../Data/{}/Disc/Original/{}.iso".format(repo_name, repo_name)
new_path = "../Data/{}/Disc/New/{}.iso".format(repo_name, repo_name)
subprocess.run(["xdelta", "-s", original_path, new_path, xdelta_name])
def upload_xdelta(xdelta_name, folder_name):
gauth = GoogleAuth()
drive = GoogleDrive(gauth)
xdelta_name = r"G:\TalesHacking\PythonLib_Playground\Data\Tales-Of-Rebirth\Disc\New\Tales-Of-Rebirth_patch.xdelta"
folder_id = '1txy2BI8tTFDPT9vmIbFELW2qmxC_ZjW0'
gfile = drive.CreateFile({'parents': [{'id': folder_id}]})
file_name = os.path.basename(xdelta_name)
gfile['title'] = file_name
gfile.SetContentFile(xdelta_name)
gfile.Upload() # Upload the file.
def get_directory_path(path):
return os.path.dirname(os.path.abspath(path))
@@ -200,13 +222,11 @@ if __name__ == "__main__":
if args.file == "SLPS":
#SLPS
tales_instance.insert_Menu_File("../Data/TOR/Disc/Original/SLPS_254.50")
tales_instance.pack_Menu_File("../Data/Tales-Of-Rebirth/Disc/Original/SLPS_254.50")
ApacheAutomate.apache_job(['SLPS_254.50'], "Tales-Of-Rebirth")
print("new SLPS is found inside Data/{}/Menu/New".format(game_name))
#Other files for menu stuff
generate_xdelta_patch("Tales-Of-Rebirth", "../Data/Tales-Of-Rebirth/Disc/New/Tales-Of-Rebirth_patch.xdelta")
if args.action == "unpack":
if args.file == "Main":

Binary file not shown.

Binary file not shown.