šŸ” Code Extractor

function test_complete_replica_build

Maturity: 50

Tests the complete local replica build process for a reMarkable device by creating a local copy of all content including folders, documents, notebooks, and PDFs with comprehensive statistics and logging.

File:
/tf/active/vicechatdev/e-ink-llm/cloudtest/test_complete_suite.py
Lines:
82 - 133
Complexity:
moderate

Purpose

This function serves as a test harness for validating the complete replica building functionality of a reMarkable device synchronization system. It creates a local replica directory, builds a complete copy of all reMarkable content, tracks performance metrics, displays detailed statistics about the sync operation, and shows the resulting directory structure. It's designed for testing, debugging, and demonstrating the replica building capabilities.

Source Code

def test_complete_replica_build(session):
    """Test complete local replica build"""
    print("\n" + "=" * 70)
    print("šŸ—ļø TESTING COMPLETE LOCAL REPLICA BUILD")
    print("=" * 70)
    
    try:
        # Create replica builder
        replica_dir = Path.cwd() / "remarkable_complete_replica"
        replica = RemarkableLocalReplica(session, str(replica_dir))
        
        print(f"šŸ“ Replica directory: {replica_dir}")
        print(f"šŸš€ Starting complete replica build...")
        print(f"   This may take several minutes depending on content size...")
        
        start_time = time.time()
        
        # Build complete replica
        success = replica.build_complete_replica()
        
        end_time = time.time()
        duration = end_time - start_time
        
        if success:
            print(f"\nšŸŽ‰ COMPLETE REPLICA BUILD SUCCESSFUL!")
            print(f"   ā±ļø Build duration: {duration:.1f} seconds")
            print(f"   šŸ“Š Statistics:")
            print(f"     šŸ“ Total nodes: {replica.stats['total_nodes']}")
            print(f"     šŸ“‚ Folders: {replica.stats['folders']}")
            print(f"     šŸ“„ Documents: {replica.stats['documents']}")
            print(f"     šŸ“” Notebooks: {replica.stats['notebooks']}")
            print(f"     šŸ“„ PDFs extracted: {replica.stats['pdfs_extracted']}")
            print(f"     šŸ“ Notebooks extracted: {replica.stats['notebooks_extracted']}")
            print(f"     šŸ“Ž Total files extracted: {replica.stats['total_files']}")
            print(f"   šŸ“ Replica location: {replica_dir}")
            print(f"   šŸ’¾ Database: {replica.database_file}")
            print(f"   šŸ“‹ Sync log: {replica.sync_log_file}")
            
            # Show directory structure
            print(f"\nšŸ“‹ REPLICA DIRECTORY STRUCTURE:")
            show_directory_tree(replica_dir, max_depth=3)
            
            return True
        else:
            print("āŒ Complete replica build failed")
            return False
            
    except Exception as e:
        print(f"āŒ Complete replica build error: {e}")
        import traceback
        traceback.print_exc()
        return False

Parameters

Name Type Default Kind
session - - positional_or_keyword

Parameter Details

session: An authenticated session object (likely from RemarkableAuth) that provides the necessary credentials and connection to interact with the reMarkable cloud API. This session must be valid and authenticated before calling this function.

Return Value

Returns a boolean value: True if the complete replica build was successful (all content downloaded and organized properly), False if the build failed or encountered errors. The function also prints extensive console output with progress updates, statistics, and error messages.

Dependencies

  • pathlib
  • time
  • traceback
  • sys

Required Imports

from pathlib import Path
import time
from auth import RemarkableAuth
from discovery import RemarkableDiscovery
from local_replica import RemarkableLocalReplica
import traceback

Conditional/Optional Imports

These imports are only needed under specific conditions:

import traceback

Condition: only when an exception occurs during replica build to print detailed stack trace

Required (conditional)

Usage Example

from auth import RemarkableAuth
from pathlib import Path
import time
from local_replica import RemarkableLocalReplica
import traceback

# First authenticate with reMarkable
auth = RemarkableAuth()
session = auth.authenticate()

# Run the complete replica build test
if session:
    success = test_complete_replica_build(session)
    if success:
        print('Replica build completed successfully')
        # Access the replica at: ./remarkable_complete_replica/
    else:
        print('Replica build failed')
else:
    print('Authentication failed')

Best Practices

  • Ensure the session object is properly authenticated before calling this function
  • Be aware that this function may take several minutes to complete depending on the amount of content
  • Ensure sufficient disk space is available before running, as it downloads all reMarkable content
  • The function creates a directory named 'remarkable_complete_replica' in the current working directory - ensure this doesn't conflict with existing directories
  • Monitor console output for progress updates and error messages during execution
  • The function includes comprehensive error handling with traceback printing for debugging
  • Review the statistics output to verify all expected content was synchronized
  • Check the generated sync log file for detailed operation history
  • The function is designed for testing purposes and includes verbose console output that may not be suitable for production use
  • Consider implementing cleanup of the replica directory between test runs to avoid conflicts

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function run_complete_test_suite 78.1% similar

    Orchestrates a complete test suite for reMarkable cloud integration, running authentication, basic discovery, and complete replica build tests in sequence.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/test_complete_suite.py
  • function main_v15 73.7% similar

    A test function that uploads a PDF document to reMarkable cloud, syncs the local replica, and validates the upload with detailed logging and metrics.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/test_raw_upload.py
  • class RemarkableReplicaSync 73.7% similar

    A class that synchronizes reMarkable cloud documents to a local replica directory, downloading and organizing folders and documents in a hierarchical structure.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/sync_replica_new.py
  • class RemarkableLocalReplica 71.9% similar

    Builds and maintains a complete local replica of reMarkable cloud

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/local_replica.py
  • function main_v100 71.1% similar

    Tests uploading a PDF document to a specific folder ('Myfolder') on a reMarkable device and verifies the upload by syncing and checking folder contents.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/test_folder_upload.py
← Back to Browse