Hardware-Target-Game-Database
Hardware-Target-Game-Database copied to clipboard
File Deletion
I'm able to do use the parse tool just fine, but when I run the build_pack.py
script, it spits out an error and deletes a rom file. What's going on that's causing this? I'm using Python 3.8.5 in the Windows command line.
D:\Users\Shentok\Downloads\New folder>build_pack.py -i "D:\Users\Shentok\Downloads\New folder\GB" -d "D:\Users\Shentok\Downloads\New folder\GB.txt" -o "D:\Users\Shentok\Downloads\New folder\GBO"
Traceback (most recent call last):
File "D:\Users\Shentok\Downloads\New folder\build_pack.py", line 136, in copy_file
copy_fn(source, dest)
File "C:\Users\Shentok\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 261, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\Users\\Shentok\\Downloads\\New folder\\GB\\4 in 1 (Europe) (4B-001, Sachen-Commin) (Unl).gb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Users\Shentok\Downloads\New folder\build_pack.py", line 311, in <module>
parse_folder(SOURCE_FOLDER, DATABASE, OUTPUT_FOLDER)
File "D:\Users\Shentok\Downloads\New folder\build_pack.py", line 239, in parse_folder
copy_file(info['filename'], new_file, original)
File "D:\Users\Shentok\Downloads\New folder\build_pack.py", line 140, in copy_file
copy_fn(source, fixed_dest)
File "C:\Users\Shentok\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 261, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\Users\\Shentok\\Downloads\\New folder\\GB\\4 in 1 (Europe) (4B-001, Sachen-Commin) (Unl).gb'
@Shentokk I was not able to reproduce your issue yet. A test on Linux runs as expected:
python3 build_pack.py -i ./GBO/ -d GB_SMDB.txt -o ./GB/ -m missing.txt
processing file: 5147 / 5147
coverage: 10152/10517 (96.53%)
The problem does not seem to come from 4 in 1 (Europe) (4B-001, Sachen-Commin) (Unl).gb
, as it is copied:
find ./GB*/ -name "*4B-001, Sachen-Commin*"
./GB/EverDrive GB/1 Game Boy/2 Unlicensed - A-Z/4 in 1 (Europe) (4B-001, Sachen-Commin) (Unl).gb
./GBO/1 Game Boy/2 Unlicensed - A-Z/4 in 1 (Europe) (4B-001, Sachen-Commin) (Unl).gb
This file occurs only once in the pack, so this is not an issue of "move-once fail to find it again". It could be a Windows-specific issue, or an issue with your ROM files. Is that file the first one in your source ROM folder?
I ran build_pack.py on my Windows machine and not having any issues.
D:\tmp>build_pack.py -i GB_unparsed -d "EverDrive GB SMDB.txt" -o GB_parsed -m GB_missing.txt
processing file: 5147 / 5147
coverage: 10152/10517 (96.53%)
Looks like it only happens when I parse my own packs as using the provided ones work fine. Also it doesn't only delete that rom, it deletes whatever rom is next on the list.
Same problem happens for me (on Windows).
I found that problem only appears when i using absolute paths for arguments.
python parse_pack.py -f "e:\path\to\NES" -o "e:\path\to\NES\db.txt"
python build_pack.py -i "e:\path\to\NES" -d "e:\path\to\NES\db.txt" -o "e:\path\to\NESPACK" -m "e:\path\to\NESPACK\Missing.txt"
When scripts and all the folders in same place, then all works fine.
python parse_pack.py -f "NES" -o "NES\db.txt"
python build_pack.py -i "NES" -d "NES\db.txt" -o "NESPACK" -m "NESPACK\Missing.txt"
Thanks @den1n that's very helpful.
I don't have a Windows machine with me at the moment, so I can't test that hypothesis. I think this is an issue that could be fixed by using os.path.normpath()
on the target_folder
and output_file
variables of the main()
function in parse_pack.py
. Maybe like that:
if __name__ == '__main__':
args = option_parse()
TARGET_FOLDER = os.path.normpath(args.target_folder)
OUTPUT_FILE = os.path.normpath(args.output_file)
END_LINE = "\n" if args.new_line else "\r"
if os.path.lexists(TARGET_FOLDER):
parse_folder(TARGET_FOLDER, OUTPUT_FILE)
I run my scripts on Windows with absolute file paths via batch files and I don't see this problem. @Shentokk You mention that the issue only happens on your packs and not the provided ones. I suspect it may have something to do with your custom SMDB. Would you be able to post your SMDB file?