Exemple #1
0
    def load_proxy_history(self, file_path):
        print(get_localized_string("loading_proxy_history") + file_path)
        if not os.path.isfile(file_path):
            print_localized("history_not_found")
            return

        s = None
        with open(file_path, 'r', encoding='utf8', errors='ignore') as f:
            s = f.read()
        j = json.loads(s)
        self.proxy_history = j["proxy_history"]
        self.non_special_proxy_history = j["non_special_proxy_history"]
        return
Exemple #2
0
    def save_proxy_history(self, file_path):
        print(get_localized_string("saving_proxy_history") + file_path)
        s = json.dumps(
            {
                "proxy_history": self.proxy_history,
                "non_special_proxy_history": self.non_special_proxy_history
            },
            indent=4,
            separators=(',', ': '))

        with open(file_path, 'w', encoding='utf8') as f:
            f.write(s)

        return
def get_mods_root_path():
    path = os.path.expanduser("~/Documents/My Games/Tabletop Simulator/")
    while True:
        if os.path.isdir(os.path.join(path, "Mods")) and os.path.isdir(os.path.join(path, "Mods", "Workshop")):
            break
        elif path == "":
            print_localized("no_folder")
            exit(0)
        else:
            print_localized("show_file")

        root = Tk()
        root.withdraw()
        path = filedialog.askdirectory(
            initialdir=path,
            title=get_localized_string("choose_root")
        )
    return path
def do_backup_folder(file_path):
    backup_path = file_path + "BACKUP"
    if not os.path.isdir(backup_path):
        print(get_localized_string("no_backup_found") + backup_path)
        shutil.copytree(file_path, backup_path)
    return
Exemple #5
0
    history_location = os.path.join(get_documents_root(),
                                    "TurkeyifierHistory.json")

    # Proxying json mod files
    p.load_proxy_history(history_location)

    if just_updated:
        # Revert old proxies
        p.proxify_mod_files_in_folder_list(mods_list, True)
        p.reset_proxy_history(history_location)

    # Do proxy calculations and save
    p.proxify_mod_files_in_folder_list(mods_list, False)
    p.save_proxy_history(history_location)

    # Fixing previously downloaded Image and Model cache
    print_localized("fixing_links")
    print_localized("require_admin_for_links")
    admin_or_exit(__file__)
    sym_link_already_downloaded_files(p, asset_folder_list)

    # DONE!
    print_localized("process_finished")
    print_localized("done")

    # Press Enter to continue...
    input(get_localized_string("press_enter"))

    exit(0)