Ejemplo n.º 1
0
def reload_maslow(module: str, _connection=None):
    output = sims4.commands.CheatOutput(_connection)

    try:
        dirname = get_sims_documents_directory() + "Mods/ts4multiplayer"
        filename = os.path.join(dirname, module) + ".py"
        reloaded_module = reload.reload_file(filename)
        output("Reloading {}".format(filename))

        for root, dirnames, filenames in os.walk(dirname):
            for a in range(0, len(filenames)):
                if filenames[a].split("\n")[-1] == module + ".py":
                    filename = filenames[a]
                    output(os.path.join(root, filename))

                    reloaded_module = reload.reload_file(
                        os.path.join(root, filename))
                    output("Reloading {}".format(filename))

        if reloaded_module is not None:
            output("Done reloading!")
        else:
            output("Error loading module or module does not exist")

    except Exception as e:
        output("Reload failed: ")

        for v in e.args:
            output(v)
Ejemplo n.º 2
0
def reload_folder(path: str) -> None:
    """
    Reloads all the python files in a folder and all sub-folders

    :param path: Folder to reload
    :return: Nothing
    """

    for root, dirs, files in os.walk(path):
        for filename in fnmatch.filter(files, "*.py"):
            reload_file(root + os.sep + filename)
Ejemplo n.º 3
0
def _devmode_reload(module: str = "", _connection: int = None) -> None:
    """
    Provides functionality to reload a module while in devmode

    Type in:
    devmode.reload [path.of.module] to reload the module

    :param module: Path of the module to reload
    :param _connection: Provided by the game
    :return: Nothing
    """

    # Get ability to write to the cheat console and build path to project folder
    output = sims4.commands.CheatOutput(_connection)
    project_folder = str(Path(__file__).parent.parent)

    # Stop here if a module path wasn't given, in this case reload the whole project
    if not module:
        reload_folder(os.path.join(project_folder, "Scripts"))
        output("Reloaded entire project")
        return

    # Convert module path to a path and build a reload path
    sub_path = module.replace(".", os.sep)
    reload_path = os.path.join(project_folder, "Scripts", sub_path)

    # If it's a folder that exists reload the whole folder
    if os.path.exists(reload_path):
        if os.path.isdir(reload_path):
            reload_folder(reload_path)
            print("Reloaded Folder: " + sub_path)
            return
        else:
            print("Unknown file to reload" + sub_path)
            return

    # Assume it's a python file

    # If it doesn't exist then warn the user and stop here
    if not os.path.exists(reload_path + ".py"):
        output("Error: The file or folder doesn't exist to reload")
        output(sub_path + "[.py]")
        return

    # Issue the reloading and notify user
    reload_file(reload_path + ".py")
    output("Reloaded: " + sub_path + ".py")
Ejemplo n.º 4
0
def reload_maslow(module: str, _connection=None):
    output = sims4.commands.CheatOutput(_connection)

    try:
        dirname = get_sims_documents_directory()
        filename = os.path.join(dirname, module) + ".py"

        output("Reloading {}".format(filename))

        reloaded_module = reload.reload_file(filename)

        if reloaded_module is not None:
            output("Done reloading!")
        else:
            output("Error loading module or module does not exist")

    except Exception as e:
        output("Reload failed: ")

        for v in e.args:
            output(v)
Ejemplo n.º 5
0
def reload_console_gui(_connection=None):
    import sims4.reload as r
    output = sims4.commands.CheatOutput(_connection)

    global _run_thread
    _run_thread = False

    try:
        dirname = os.path.dirname(os.path.realpath(__file__))

        filename = os.path.join(dirname, "consolegui") + ".py"

        output("Reloading {}".format(filename))
        reloaded_module = r.reload_file(filename)

        if reloaded_module is not None:
            output("Done reloading!")
        else:
            output("Error loading module or module does not exist")

    except BaseException as e:
        output("Reload failed: ")
        for v in e.args:
            output(v)