function show_current_root
Fetches and displays the current root.docSchema from the reMarkable cloud sync service, showing metadata and analyzing document entries.
/tf/active/vicechatdev/e-ink-llm/cloudtest/show_current_root.py
8 - 80
moderate
Purpose
This function authenticates with the reMarkable cloud API, retrieves the current root document schema (which contains the file system structure), and provides a detailed analysis including the root hash, generation number, schema version, and a breakdown of all entries by type (folders, PDFs, notebooks). It's useful for debugging, understanding the reMarkable cloud storage structure, or auditing the current state of a user's documents.
Source Code
def show_current_root():
print("š Fetching Current Root.docSchema")
print("=" * 50)
# Authenticate
auth = RemarkableAuth()
session = auth.get_authenticated_session()
if not session:
print("ā Authentication failed")
return
try:
# Get current root info
print("š Step 1: Getting root info...")
root_response = session.get("https://eu.tectonic.remarkable.com/sync/v4/root")
root_response.raise_for_status()
root_data = root_response.json()
print(f"ā
Root hash: {root_data['hash']}")
print(f"ā
Generation: {root_data.get('generation')}")
print(f"ā
Schema version: {root_data.get('schemaVersion')}")
# Get root.docSchema content
print(f"\nš Step 2: Fetching root.docSchema content...")
root_content_response = session.get(f"https://eu.tectonic.remarkable.com/sync/v3/files/{root_data['hash']}")
root_content_response.raise_for_status()
root_content = root_content_response.text
print(f"ā
Content size: {len(root_content)} bytes")
# Display content with line numbers
print(f"\nš Current Root.docSchema Content:")
print("-" * 100)
lines = root_content.strip().split('\n')
for i, line in enumerate(lines):
print(f"Line {i:2d}: {line}")
print("-" * 100)
# Analyze entries
print(f"\nš Analysis:")
if len(lines) > 0:
version = lines[0]
entries = lines[1:] if len(lines) > 1 else []
print(f" Version: {version}")
print(f" Total entries: {len(entries)}")
# Categorize entries
types = {}
for entry in entries:
if ':' in entry:
parts = entry.split(':')
if len(parts) >= 4:
entry_type = parts[3]
if entry_type not in types:
types[entry_type] = 0
types[entry_type] += 1
print(f" Entry types:")
for entry_type, count in types.items():
type_name = {
'1': 'Unknown/Special',
'2': 'Folder',
'4': 'PDF Document',
'5': 'Notebook'
}.get(entry_type, f'Type {entry_type}')
print(f" Type {entry_type} ({type_name}): {count}")
else:
print(" ā Empty or invalid root.docSchema")
except Exception as e:
print(f"ā Error: {e}")
Return Value
This function returns None. It outputs all information directly to stdout via print statements, including authentication status, root metadata (hash, generation, schema version), the complete root.docSchema content with line numbers, and statistical analysis of entry types.
Dependencies
requestsauth
Required Imports
from auth import RemarkableAuth
Usage Example
from auth import RemarkableAuth
def show_current_root():
# ... function code ...
pass
# Simply call the function to display current root schema
show_current_root()
# Output will be printed to console showing:
# - Authentication status
# - Root hash and metadata
# - Complete root.docSchema content
# - Analysis of document types and counts
Best Practices
- Ensure RemarkableAuth is properly configured before calling this function
- This function makes network requests and may take time depending on connection speed
- The function prints directly to stdout; redirect output if you need to capture it programmatically
- Handle potential network failures gracefully - the function catches exceptions but may still fail on network issues
- The API endpoint is hardcoded to 'eu.tectonic.remarkable.com' - may need modification for other regions
- This is a read-only operation and does not modify any data on the reMarkable cloud
- Consider rate limiting if calling this function repeatedly to avoid API throttling
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class RootCleaner 72.8% similar
-
function test_root_finding 70.8% similar
-
class RootDocSchemaRepair 70.0% similar
-
function verify_document_status 67.7% similar
-
function main_v23 66.5% similar