Recherche avancée

Médias (1)

Mot : - Tags -/iphone

Autres articles (77)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

Sur d’autres sites (8586)

  • Revision 34808 : class url pour le lien et non org (site VS société, merci tetue)

    31 janvier 2010, par brunobergot@… — Log

    class url pour le lien et non org (site VS société, merci tetue)

  • Revision 35507 : une erreur grossière de caractères en trop

    23 février 2010, par kent1@… — Log

    une erreur grossière de caractères en trop

  • Button "Clean FFMeta" does nothing after compiling with PyInstaller

    6 mai, par Leonie Holdermann

    I’m working on my first Python project and I’ve compiled it into an executable using PyInstaller with the following command :

    


    pyinstaller --onefile --noconsole app.py


    


    However, when I run the executable, the button "Clean FFMeta" which triggers the clean_ffmeta() function does nothing. Additionally, changing the language or the chapter settings under the "Options -> Chapter settings" menu doesn’t seem to affect anything either. It all works perfectly in the Python script before compilation, but once compiled into an .exe, none of these functions respond.

    


    I've reviewed the code, and the button is correctly linked to the function, but I suspect something might be going wrong during the compilation process.

    


    What I have tried :

    


      

    • Checked that all dependencies are included.
    • 


    • Verified that the configuration and language changes are being correctly applied before compilation.
    • 


    • Tried running the executable from a console to check for error messages, but there are none visible (since I used —noconsole).
    • 


    


    What I expect :

    


      

    • The "Clean FFMeta" button should clean the FFMeta file based on the
user settings.
    • 


    • Language and chapter settings should be updated and reflected in the GUI immediately.
    • 


    


    Code :
Below is a simplified version of my code, especially the sections related to the "Clean FFMeta" functionality and language/chapter settings.

    


    def clean_ffmeta():
if not config.get("cd_in_path"):
    show_error(texts[current_language]["error"] + " No CD_IN path configured.")
    return

chapter_path = os.path.join(config["cd_in_path"], "chapters.ffmeta")
cleaned_chapter_path = os.path.join(config["cd_in_path"], "chapters_cleaned.ffmeta")

if not os.path.exists(chapter_path):
    show_error(texts[current_language]["no_chapters_file"])
    return

write_to_console("Starting to clean FFMeta...")
thread = threading.Thread(target=clean_ffmeta_thread, args=(chapter_path, cleaned_chapter_path))
thread.start()

def clean_ffmeta_thread(chapter_path, cleaned_chapter_path):
    try:
        chapter_action = config.get("chapter_action", "clean")
        keep_empty = config.get("chapter_keep_empty", False)

        write_to_console(f"Chapter action: {chapter_action}, Keep empty: {keep_empty}")

        with open(chapter_path, "r", encoding="utf-8") as f:
            lines = f.readlines()

        new_lines = []
        chapter_counter = 0

        for line in lines:
            stripped_line = line.strip()
            if stripped_line.startswith("title="):
                title_content = stripped_line[6:]
                
                if chapter_action == "clean":
                    if title_content == "":
                        if keep_empty:
                            new_lines.append(line)
                        else:
                            write_to_console("Empty title skipped.")
                            continue
                    else:
                        new_lines.append(line)
                
                elif chapter_action == "number":
                    chapter_counter += 1
                    chapter_title = f"{texts[current_language]['chapter']} {chapter_counter}"
                    new_lines.append(f"title={chapter_title}\n")
                    write_to_console(f"Renamed to: {chapter_title}")
            else:
                new_lines.append(line)

        with open(cleaned_chapter_path, "w", encoding="utf-8") as f:
            f.writelines(new_lines)

        write_to_console(f"FFMeta cleaned and saved as '{cleaned_chapter_path}'.")

    except Exception as e:
        write_to_console(f"Error cleaning FFMeta: {str(e)}")

def open_chapter_settings():
    global chapter_settings_window, chapter_action_var
    global chapter_keep_empty_checkbox, chapter_save_button

    chapter_settings_window = tk.Toplevel(root)
    chapter_settings_window.title(texts[current_language]["chapter_setting_title"])
    chapter_settings_window.geometry("300x250")
    chapter_settings_window.resizable(False, False)
    
    chapter_action_var = tk.StringVar(value=config.get("chapter_action", "clean"))
    chapter_keep_empty_var = tk.BooleanVar(value=config.get("chapter_keep_empty", False))
    
    tk.Label(
        chapter_settings_window,
        text=texts[current_language]["chapter_setting_choose_option"]
    ).pack(pady=(10, 5))
    
    tk.Radiobutton(
        chapter_settings_window,
        text=texts[current_language]["chapter_setting_clean"],
        variable=chapter_action_var,
        value="clean"
    ).pack(pady=5)

    tk.Radiobutton(
        chapter_settings_window,
        text=texts[current_language]["chapter_setting_number"],
        variable=chapter_action_var,
        value="number"
    ).pack(pady=5)

    chapter_keep_empty_checkbox = tk.Checkbutton(
        chapter_settings_window,
        text=texts[current_language]["chapter_setting_keep_empty"],
        variable=chapter_keep_empty_var
    )
    chapter_keep_empty_checkbox.pack(pady=5)

    chapter_save_button = tk.Button(
        chapter_settings_window,
        text=texts[current_language]["chapter_setting_save"],
        command=lambda: save_chapter_settings(chapter_keep_empty_var, chapter_settings_window)
    )
    chapter_save_button.pack(pady=10)

def save_chapter_settings(keep_empty_var, window):
    config["chapter_action"] = chapter_action_var.get()
    config["chapter_keep_empty"] = keep_empty_var.get()
    save_config()
    write_to_console(f"Chapter settings saved: Action={config['chapter_action']}, Keep empty={config['chapter_keep_empty']}")
    window.destroy()

options_menu = tk.Menu(menu, tearoff=0)
options_menu.add_command(label="Check pip-ffmpeg", command=check_pip_ffmpeg)
options_menu.add_command(label=texts[current_language]["menu_chapter_settings"], command=open_chapter_settings)
menu.add_cascade(label="Options", menu=options_menu)

btn3 = tk.Button(btn_frame, text="3. Clean FFMeta", command=clean_ffmeta)
btn3.grid(row=0, column=2, padx=5)


    


    Here you find the entire project code of the entire project : https://www.pythonmorsels.com/p/32hkh/

    


    Why is the clean_chapters function not working ?