Skip to content

I just compared this and I didn't get a good comparison... #97

@fast-blender-add-ons-dot-com

Description

def anonymous_error_collecting(full_error_message, global_iteration):
"""
Collects anonymous error data and sends it to a remote repository if the same error
repeats for a specified number of iterations.

Parameters:
- full_error_message (str): The complete error message to process.
- global_iteration (int): The current iteration count of the process.

Improvements:
- Encapsulated state management within the manager to avoid global variables.
- Added a buffer before sending data to avoid sending data too frequently.
- Enhanced checks for anonymous data collection for safer data handling.
"""
# Retrieve the scene and manager for accessing Blender settings
scn = bpy.context.scene
manager = bpy.context.preferences.addons[__name__].preferences.Prop

# Define the maximum iterations before sending an error
max_iterations = scn.gpt_max_iterations

# Ensure the manager tracks the last error message and count
if not hasattr(manager, 'last_error_message'):
    manager.last_error_message = None
if not hasattr(manager, 'error_count'):
    manager.error_count = 0

# Check if anonymous data collection is enabled
if scn.gpt_send_anonymous_data:
    if global_iteration == 1 or manager.last_error_message != full_error_message:
        # Initialize or update for a new error message
        manager.last_error_message = full_error_message
        manager.error_count = 1
    else:
        # Increment the error count for repeated errors
        manager.error_count += 1
        if manager.error_count >= max_iterations:
            # Send the error if the threshold is reached and reset the count
            append_error_to_github(full_error_message)
            print_color("AR", "\nAnonymous Data Collected: ", new_line=False)
            print_color("AY", f"Error message sent to GitHub after ", new_line=False)
            print_color("AB", f"{max_iterations}", new_line=False)
            print_color("AY", " iterations.")
            
            # Clear the last message and reset the count
            manager.last_error_message = None
            manager.error_count = 0

def anonymous_error_collecting(full_error_message, global_iteration):

global last_error_message, error_count

scn = bpy.context.scene
manager = bpy.context.preferences.addons[__name__].preferences.Prop

max_iterations = scn.gpt_max_iterations

if scn.gpt_send_anonymous_data:
    if global_iteration == 1:
        last_error_message = full_error_message
        error_count = 1
    else:
        if full_error_message == last_error_message:
            # print_color("AB", f"\nERROR REPEATED ", new_line=False)
            # print_color("AR", f"{error_count}", new_line=False)
            # print_color("AY", f" ITERATIONS.")
            error_count += 1
            if error_count >= max_iterations - 1:
                append_error_to_github(full_error_message)
                print_color("AR", f"\nAnonymous Data Collected: ", new_line=False)
                print_color("AY", f"Error message sent to GitHub after ", new_line=False)
                print_color("AB", f"{max_iterations}", new_line=False)
                print_color("AY", f" iterations.")
                error_count = 0  # Reset error count after sending
        else:
            last_error_message = full_error_message
            error_count = 1

Just let me know if that's enough information if you try him out I did it by comparing it with clipboard and the above version at the top is the clipboard

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