function verify_cloud_empty
Verifies that a reMarkable cloud storage account is completely empty by authenticating, retrieving the root document schema, and analyzing its contents for any remaining documents or folders.
/tf/active/vicechatdev/e-ink-llm/cloudtest/verify_cloud_empty.py
11 - 124
complex
Purpose
This function is designed to validate that a reMarkable cloud storage has been successfully cleared of all content. It authenticates with the reMarkable cloud API, retrieves the root document schema, parses the content to identify any remaining documents or folders, and provides detailed analysis including item names, types, and metadata. It's particularly useful for testing cleanup operations or verifying account state before/after bulk operations.
Source Code
def verify_cloud_empty():
"""Verify that the cloud storage is empty"""
print("š Verifying Cloud Content Removal")
print("=" * 50)
# Authenticate
auth = RemarkableAuth()
session = auth.get_authenticated_session()
if not session:
print("ā Authentication failed")
return False
try:
# Get current root info
print("š Getting current root.docSchema...")
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')}")
# Get root 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")
print(f"š Root.docSchema content:")
print(f" {repr(root_content)}")
# Parse content
lines = root_content.strip().split('\n')
print(f"\nš Analysis:")
print(f" Total lines: {len(lines)}")
if len(lines) <= 1:
print("ā
Cloud appears to be EMPTY (only version header or less)")
return True
print(f" Version: {lines[0] if lines else 'None'}")
document_count = 0
folder_count = 0
for i, line in enumerate(lines[1:], 1):
if line.strip(): # Non-empty line
print(f" Line {i}: {line}")
# Try to parse the line
parts = line.split(':')
if len(parts) >= 5:
doc_hash = parts[0]
doc_uuid = parts[2]
doc_type = parts[3]
doc_size = parts[4]
print(f" UUID: {doc_uuid}")
print(f" Type: {doc_type}")
print(f" Size: {doc_size}")
# Try to get name from metadata
try:
doc_response = session.get(f"https://eu.tectonic.remarkable.com/sync/v3/files/{doc_hash}")
if doc_response.status_code == 200:
doc_content = doc_response.text
doc_lines = doc_content.strip().split('\n')
# Find metadata
for doc_line in doc_lines[1:]:
if ':' in doc_line and '.metadata' in doc_line:
metadata_parts = doc_line.split(':')
if len(metadata_parts) >= 5:
metadata_hash = metadata_parts[0]
metadata_response = session.get(f"https://eu.tectonic.remarkable.com/sync/v3/files/{metadata_hash}")
if metadata_response.status_code == 200:
metadata = json.loads(metadata_response.text)
name = metadata.get('visibleName', 'Unknown')
item_type = metadata.get('type', 'Unknown')
deleted = metadata.get('deleted', False)
parent = metadata.get('parent', '')
print(f" Name: {name}")
print(f" Item Type: {item_type}")
print(f" Deleted: {deleted}")
print(f" Parent: {parent or '(root)'}")
if item_type == 'CollectionType':
folder_count += 1
elif item_type == 'DocumentType':
document_count += 1
break
break
except Exception as e:
print(f" ā ļø Could not fetch details: {e}")
print()
print(f"š SUMMARY:")
print(f" Documents found: {document_count}")
print(f" Folders found: {folder_count}")
print(f" Total items: {document_count + folder_count}")
if document_count == 0 and folder_count == 0:
print("ā
Cloud is COMPLETELY EMPTY")
return True
else:
print("ā Cloud still contains content")
return False
except Exception as e:
print(f"ā Error checking cloud content: {e}")
return False
Return Value
Returns a boolean value: True if the cloud storage is completely empty (contains only version header or no content), False if any documents or folders are found or if an error occurs during verification. The function also prints detailed diagnostic information to stdout during execution.
Dependencies
jsonrequests
Required Imports
import json
from auth import RemarkableAuth
Usage Example
# Verify if reMarkable cloud storage is empty
is_empty = verify_cloud_empty()
if is_empty:
print("Cloud storage verified as empty")
else:
print("Cloud storage still contains items")
# Example output:
# š Verifying Cloud Content Removal
# ==================================================
# š Getting current root.docSchema...
# ā
Current root hash: abc123...
# ā
Current generation: 42
# ā
Root.docSchema size: 80 bytes
# š Root.docSchema content:
# '80\n'
# š Analysis:
# Total lines: 1
# ā
Cloud appears to be EMPTY (only version header or less)
Best Practices
- This function performs multiple API calls and may take time to complete, especially if many items exist in the cloud
- The function prints extensive diagnostic output to stdout; consider redirecting or capturing output if used in automated systems
- Authentication must be properly configured before calling this function
- The function makes synchronous HTTP requests; ensure network connectivity is stable
- Error handling is present but errors are printed rather than raised; check the return value for success/failure
- The function is hardcoded to use the EU region endpoint (eu.tectonic.remarkable.com); may need modification for other regions
- Metadata parsing assumes specific reMarkable API response formats; API changes may break functionality
- The function attempts to fetch detailed metadata for each item found, which can be slow for large numbers of items
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class RootCleaner 75.0% similar
-
function test_remarkable_authentication 73.7% similar
-
function main_v23 73.0% similar
-
function verify_document_status 72.3% similar
-
function test_remarkable_auth 69.9% similar