function verify_document_status
Verifies the current status and metadata of a specific test document in the reMarkable cloud sync system by querying the sync API endpoints and analyzing the document's location and properties.
/tf/active/vicechatdev/e-ink-llm/cloudtest/verify_document_status.py
13 - 153
complex
Purpose
This diagnostic function performs a comprehensive check of a hardcoded test document (UUID: 206f5df3-07c2-4341-8afd-2b7362aefa91) in the reMarkable cloud storage. It retrieves the root document schema, locates the target document, fetches its metadata, and analyzes its current folder location (root, trash, or gpt_in folder). The function is designed for debugging and verification purposes to ensure documents are properly synced and located in the expected folders within the reMarkable ecosystem.
Source Code
def verify_document_status():
"""Check current status of the test document"""
# Load auth session
auth = RemarkableAuth()
session = auth.get_authenticated_session()
if not session:
print("ā Failed to authenticate")
return False
print("š Verifying Current Document Status")
print("=" * 50)
target_doc_uuid = "206f5df3-07c2-4341-8afd-2b7362aefa91"
try:
# Step 1: Get current root.docSchema
print("\nš Step 1: Getting current root.docSchema from server...")
root_response = session.get("https://eu.tectonic.remarkable.com/sync/v4/root")
root_response.raise_for_status()
root_data = root_response.json()
print(f"ā
Current root hash: {root_data['hash']}")
print(f"ā
Current generation: {root_data.get('generation')}")
# Step 2: Get root 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"ā
Root.docSchema size: {len(root_content)} bytes")
# Step 3: Find our document
print(f"\nš Step 3: Looking for document {target_doc_uuid[:8]}... in root.docSchema")
doc_entry = None
doc_hash = None
for line in root_content.strip().split('\n')[1:]: # Skip version
if target_doc_uuid in line:
doc_entry = line
parts = line.split(':')
if len(parts) >= 5:
doc_hash = parts[0]
break
if not doc_entry:
print(f"ā Document {target_doc_uuid} NOT found in root.docSchema")
print(f"š Current root.docSchema content:")
for i, line in enumerate(root_content.strip().split('\n')):
print(f" {i}: {line}")
return False
print(f"ā
Found document entry: {doc_entry}")
print(f"ā
Document hash: {doc_hash}")
# Step 4: Get document's current docSchema
print(f"\nš Step 4: Fetching document's docSchema...")
doc_response = session.get(f"https://eu.tectonic.remarkable.com/sync/v3/files/{doc_hash}")
doc_response.raise_for_status()
doc_content = doc_response.text
print(f"ā
Document docSchema size: {len(doc_content)} bytes")
print(f"š Document docSchema content:")
doc_lines = doc_content.strip().split('\n')
for i, line in enumerate(doc_lines):
print(f" {i}: {line}")
# Step 5: Get current metadata
print(f"\nš Step 5: Getting current metadata...")
metadata_hash = None
for line in doc_lines[1:]: # Skip version
if ':' in line and '.metadata' in line:
parts = line.split(':')
if len(parts) >= 5:
metadata_hash = parts[0]
break
if not metadata_hash:
print(f"ā Metadata component not found")
return False
print(f"ā
Metadata hash: {metadata_hash}")
# Fetch current metadata
metadata_response = session.get(f"https://eu.tectonic.remarkable.com/sync/v3/files/{metadata_hash}")
metadata_response.raise_for_status()
current_metadata = json.loads(metadata_response.text)
print(f"\nš CURRENT METADATA:")
print(f" Document Name: {current_metadata.get('visibleName', 'N/A')}")
print(f" Parent UUID: {current_metadata.get('parent', 'N/A')}")
print(f" Parent Display: {'(root)' if current_metadata.get('parent', '') == '' else current_metadata.get('parent', 'N/A')}")
print(f" Document Type: {current_metadata.get('type', 'N/A')}")
print(f" Last Modified: {current_metadata.get('lastModified', 'N/A')}")
print(f" Created Time: {current_metadata.get('createdTime', 'N/A')}")
print(f" Deleted: {current_metadata.get('deleted', 'N/A')}")
print(f" Pinned: {current_metadata.get('pinned', 'N/A')}")
print(f"\nš FULL METADATA JSON:")
print(json.dumps(current_metadata, indent=2))
# Step 6: Check if gpt_in folder exists and its UUID
print(f"\nš Step 6: Checking gpt_in folder status...")
gpt_in_uuid = "99c6551f-2855-44cf-a4e4-c9c586558f42"
gpt_in_found = False
for line in root_content.strip().split('\n')[1:]:
if gpt_in_uuid in line:
gpt_in_found = True
print(f"ā
Found gpt_in folder: {line}")
break
if not gpt_in_found:
print(f"ā gpt_in folder ({gpt_in_uuid}) not found in root.docSchema")
# Step 7: Analysis
print(f"\nš ANALYSIS:")
parent = current_metadata.get('parent', '')
if parent == '':
print(f"š Document is currently in ROOT folder")
elif parent == 'trash':
print(f"š Document is currently in TRASH")
elif parent == gpt_in_uuid:
print(f"š Document is currently in GPT_IN folder")
else:
print(f"š Document is in UNKNOWN folder: {parent}")
print(f"š Expected gpt_in UUID: {gpt_in_uuid}")
print(f"š Actual parent UUID: {parent}")
print(f"š Match: {'ā
YES' if parent == gpt_in_uuid else 'ā NO'}")
return True
except Exception as e:
print(f"ā Verification failed: {e}")
return False
Return Value
Returns a boolean value: True if the verification process completes successfully (document found and all data retrieved), False if authentication fails, the document is not found, or any error occurs during the verification process. The function primarily outputs diagnostic information to stdout rather than returning structured data.
Dependencies
jsonrequestsauth
Required Imports
import json
import requests
from auth import RemarkableAuth
Usage Example
# Ensure auth.py module is available with RemarkableAuth class
# The function uses hardcoded document UUID and folder UUID
from verify_document_status import verify_document_status
# Run verification - outputs detailed status to console
success = verify_document_status()
if success:
print("Verification completed successfully")
else:
print("Verification failed - check console output for details")
Best Practices
- This function is hardcoded for a specific test document UUID (206f5df3-07c2-4341-8afd-2b7362aefa91) and should be modified to accept document UUID as a parameter for general use
- The function makes multiple sequential API calls which could be optimized or made concurrent for better performance
- Error handling could be improved to provide more specific error messages for different failure scenarios
- The function outputs directly to stdout using print statements - consider using logging module for production use
- The gpt_in folder UUID (99c6551f-2855-44cf-a4e4-c9c586558f42) is hardcoded and should be configurable
- Consider adding retry logic for API calls to handle transient network failures
- The function assumes the reMarkable API structure and endpoints remain stable - may need updates if API changes
- Authentication session should be properly closed or managed in a context manager to prevent resource leaks
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function check_gpt_in_folder 73.0% similar
-
function verify_cloud_empty 72.3% similar
-
function main_v6 71.1% similar
-
function main_v15 70.8% similar
-
function main_v113 70.1% similar