From eae13e209befe3db378e2bf2808c2efdba5591b8 Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Mon, 3 Mar 2025 11:43:13 +1000 Subject: [PATCH 1/3] Fix casc_extract on Python >= 3.12 (`configparser.readfp` -> `read_file`) --- casc_extract/build_cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/casc_extract/build_cfg.py b/casc_extract/build_cfg.py index 20fd3518d76..d219aaf2a1d 100644 --- a/casc_extract/build_cfg.py +++ b/casc_extract/build_cfg.py @@ -156,7 +156,7 @@ def open(self): # Slight hack to get the configuration file read easily conf_str = '[base]\n' + open(build_cfg_path, 'r').read() conf_str_fp = io.StringIO(conf_str) - self.cfg.readfp(conf_str_fp) + self.cfg.read_file(conf_str_fp) print(f'Wow build: {build_version}') From bcf4ba634410ed8db11771f4f750666c56b15efa Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Sat, 12 Jul 2025 11:16:11 +1000 Subject: [PATCH 2/3] Don't raise parser failures whn extraction fails (#10033) --- casc_extract/casc.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/casc_extract/casc.py b/casc_extract/casc.py index b75e40c25c9..54744d9bbbb 100644 --- a/casc_extract/casc.py +++ b/casc_extract/casc.py @@ -432,6 +432,7 @@ def extract_blte_file(self, file_name): def extract_data(self, file_key, file_md5sum, data_file_number, data_file_offset, blte_file_size): path = os.path.join(self.options.data_dir, 'Data', 'data', f'data.{data_file_number:03d}') + file_key_hex = codecs.encode(file_key, 'hex').decode() if not self.open(path): return None @@ -442,16 +443,20 @@ def extract_data(self, file_key, file_md5sum, data_file_number, blte_len = struct.unpack(' Date: Sat, 12 Jul 2025 11:23:58 +1000 Subject: [PATCH 3/3] Add `--continue_on_failure` option to casc_extract (workaround for #10033) --- casc_extract/casc_extract.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/casc_extract/casc_extract.py b/casc_extract/casc_extract.py index 19c14c8e1da..43316b5436a 100755 --- a/casc_extract/casc_extract.py +++ b/casc_extract/casc_extract.py @@ -33,6 +33,12 @@ parser.add_option( '--ribbit', action = 'store_true', dest = 'ribbit', default = False, help = 'Use Ribbit for configuration information') parser.add_option( '--bgdl', action = 'store_true', dest = 'bgdl', default = False, help = 'Download background downloader files' ) parser.add_option( '--custom', type='string', dest = 'custom_build', default = None, help = 'Use a custom Build Config') +parser.add_option( + '--continue_on_failure', + action='store_true', + default=False, + help='If any file fails to extract in "batch" or "unpack" mode, continue trying to extract other files', +) if __name__ == '__main__': (opts, args) = parser.parse_args() @@ -108,7 +114,11 @@ print('Extracting %s (id=%d) ...' % (file_name, file_data_id)) if not blte.extract_file(*extract_data): - sys.exit(1) + print(f'Failed to extract data for {file_name}', file=sys.stderr) + if opts.continue_on_failure: + continue + else: + sys.exit(1) else: cdn = casc.CDNIndex(opts) if not cdn.open(): @@ -151,14 +161,21 @@ result = blte.extract_buffer_to_file(data, os.path.join(output_path, file_name.replace('\\', '/'))) if not result: print('Failed to extract data for %s %s' % (opts.locale, file_name), file=sys.stderr) - sys.exit(1) + if opts.continue_on_failure: + continue + else: + sys.exit(1) elif opts.mode == 'unpack': blte = casc.BLTEExtract(opts) - for file in args: - print('Extracting %s ...') - if not blte.extract_blte_file(file): - sys.exit(1) + for file_name in args: + print(f'Extracting {file_name}...') + if not blte.extract_blte_file(file_name): + print(f'Failed to extract data for {file_name}', file=sys.stderr) + if opts.continue_on_failure: + continue + else: + sys.exit(1) elif opts.mode == 'extract': build = None