Skip to content

Updates Failing #12

@ReverseTelnet

Description

@ReverseTelnet

This may be a duplicate of (or an addition to) Issue #10.
The last cheat update is from May 2025.

However, when working through Issue #10, I ran into some of the same problems that GitHub Actions is running into attempting to update the repository.

I worked through several of the issues in a fork.
In quick summary, try/except blocks generally fixed the challenges.

Issue - No GitHub Token

CLI Error - No GitHub Token

(.venv) reverse_telnet@macbook.local ~/Documents/repos/switch-cheats-db$ python database_builder.py
Traceback (most recent call last):
  File "/Users/reverse_telnet/Documents/repos/switch-cheats-db/database_builder.py", line 172, in <module>
    highfps = HighFPSCheatsInfo()
              ^^^^^^^^^^^^^^^^^^^
  File "/Users/reverse_telnet/Documents/repos/switch-cheats-db/database_builder.py", line 65, in __init__
    self.highfps_version = self.fetch_high_FPS_cheats_version()
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/reverse_telnet/Documents/repos/switch-cheats-db/database_builder.py", line 71, in fetch_high_FPS_cheats_version
    last_commit_date = repo_info.get("commit").get("commit").get("author").get("date")
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
(.venv) reverse_telnet@macbook.local ~/Documents/repos/switch-cheats-db$

Code Fix - No GitHub Token

    def fetch_high_FPS_cheats_version(self):
        token = os.getenv('GITHUB_TOKEN')
        if token is not None:
            headers = {'Authorization': f'token {token}'}
        else:
            headers = {}
        repo_info = self.scraper.get(self.api_url, headers=headers).json()
        last_commit_date = repo_info.get("commit").get("commit").get("author").get("date")
        return date.fromisoformat(last_commit_date.split("T")[0])

Issue - Complete Folder Exists

CLI Error - Complete Folder Exists

(.venv) reverse_telnet@macbook.local ~/Documents/repos/switch-cheats-db$ python database_builder.py
Downloading cheats
Processing the cheat sheets
building complete cheat sheets
Traceback (most recent call last):
  File "/Users/reverse_telnet/Documents/repos/switch-cheats-db/database_builder.py", line 194, in <module>
    out_path.mkdir()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
FileExistsError: [Errno 17] File exists: 'complete'
(.venv) reverse_telnet@macbook.local ~/Documents/repos/switch-cheats-db$

Code Fix - Complete Folder Exists

        print("building complete cheat sheets")
        out_path = Path("complete")
        try:
            out_path.mkdir()
        except FileExistsError:
            pass
        archive_worker.build_cheat_files(cheats_path, out_path)

Issue - Title-ID Folder Exists

CLI Error - Title-ID Folder Exists

(.venv) reverse_telnet@macbook.local ~/Documents/repos/switch-cheats-db$ python database_builder.py
Downloading cheats
Processing the cheat sheets
building complete cheat sheets
Traceback (most recent call last):
  File "/Users/reverse_telnet/Documents/repos/switch-cheats-db/database_builder.py", line 198, in <module>
    archive_worker.build_cheat_files(cheats_path, out_path)
  File "/Users/reverse_telnet/Documents/repos/switch-cheats-db/database_builder.py", line 113, in build_cheat_files
    tid_path.mkdir()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
FileExistsError: [Errno 17] File exists: 'complete/titles/0100DBD013C92000'
(.venv) reverse_telnet@macbook.local ~/Documents/repos/switch-cheats-db$

Code Fix - Title-ID Folder Exists

        for tid in cheats_path.iterdir():
            tid_path = titles_path.joinpath(tid.stem)
            try:
                tid_path.mkdir()
            except FileExistsError:
                continue

Issue - Directory Not Empty

CLI Error - Directory Not Empty

(.venv) reverse_telnet@macbook.local ~/Documents/repos/switch-cheats-db$ python database_builder.py
Downloading cheats
Processing the cheat sheets
building complete cheat sheets
Creating the archives
Traceback (most recent call last):
  File "/Users/reverse_telnet/Documents/repos/switch-cheats-db/database_builder.py", line 204, in <module>
    archive_worker.create_archives("complete")
  File "/Users/reverse_telnet/Documents/repos/switch-cheats-db/database_builder.py", line 144, in create_archives
    contents_path = titles_path.rename(titles_path.parent.joinpath("contents"))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 1175, in rename
    os.rename(self, target)
OSError: [Errno 66] Directory not empty: 'complete/titles' -> 'complete/contents'
(.venv) reverse_telnet@macbook.local ~/Documents/repos/switch-cheats-db$

Code Fix - Directory Not Empty

    def create_archives(self, out_path):
        out_path = Path(out_path)
        titles_path = out_path.joinpath("titles")
        self.touch_all(titles_path)
        shutil.make_archive(str(titles_path.resolve()), "zip", root_dir=out_path, base_dir="titles")
        try:
            contents_path = titles_path.rename(titles_path.parent.joinpath("contents"))
        except OSError:
            contents_path = out_path.joinpath("contents")

Note:
It wasn't clear to me why the title directory was being renamed to contents or really how this ever worked, as the contents directory is always present. My best guess fix was to simple 'hard-code' a path as the exception catch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions