Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix def get_folder_path_info(base) for MacOS - any input? #438

Open
djbritt opened this issue Apr 4, 2024 · 0 comments
Open

Fix def get_folder_path_info(base) for MacOS - any input? #438

djbritt opened this issue Apr 4, 2024 · 0 comments

Comments

@djbritt
Copy link

djbritt commented Apr 4, 2024

This seemed to fix issues with loading a model from the models folder for MacOS, compared to what is live in the repo now. Does anyone have any input? I just used Claude to help recode this, and it seemed to help. If you guys can confirm it helps, I'll do a pull request.

File: aiserver.py

def get_folder_path_info(base):
    if base == 'This PC':
        breadcrumbs = [['This PC', 'This PC']]
        if os.name == 'nt':  # Windows
            paths = [["{}:\\".format(chr(i)), "{}:\\".format(chr(i))] for i in range(65, 91) if os.path.exists("{}:".format(chr(i)))]
        else:  # macOS/Linux
            paths = []
    else:
        path = os.path.abspath(base)
        breadcrumbs = []
        for i in range(len(path.split(os.path.sep))):
            breadcrumbs.append([os.path.sep.join(path.split(os.path.sep)[:i+1]),
                                path.split(os.path.sep)[i]])

        if len(breadcrumbs) == 1:
            if os.name == 'nt':  # Windows
                breadcrumbs = [["{}:\\".format(chr(i)), "{}:\\".format(chr(i))] for i in range(65, 91) if os.path.exists("{}:".format(chr(i)))]
            else:  # macOS/Linux
                breadcrumbs = [['/','/']]

        else:
            if os.name == 'nt':  # Windows
                if len([["{}:\\".format(chr(i)), "{}:\\".format(chr(i))] for i in range(65, 91) if os.path.exists("{}:".format(chr(i)))]) > 0:
                    breadcrumbs.insert(0, ['This PC', 'This PC'])

        paths = []
        base_path = os.path.abspath(base)
        for item in os.listdir(base_path):
            if os.path.isdir(os.path.join(base_path, item)):
                paths.append([os.path.join(base_path, item), item])

    return (paths, breadcrumbs)

Before, I was getting this error

FileNotFoundError: [Errno 2] No such file or directory: '/Users/user/github/KoboldAI-Client/\Users\user\github\KoboldAI-Client\models'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant