linux observer
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use sol CLI for registration before falling back to HTTP

When sol is installed on the same machine, use `sol remote --json create`
for registration instead of requiring the server to be running. Falls back
to HTTP registration if sol is not found or CLI fails.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+49 -9
+27 -8
src/solstone_linux/cli.py
··· 92 92 config.ensure_dirs() 93 93 save_config(config) 94 94 95 - # Auto-register 95 + # Auto-register — try sol CLI first (no server needed), fall back to HTTP 96 96 if not config.key: 97 - print("Registering with server...") 98 - client = UploadClient(config) 99 - if client.ensure_registered(config): 100 - config = load_config() 101 - print(f"Registered (key: {config.key[:8]}...)") 102 - else: 103 - print("Warning: registration failed. Run setup again when server is available.") 97 + sol = shutil.which("sol") 98 + if sol: 99 + print("Registering via sol CLI...") 100 + try: 101 + result = subprocess.run( 102 + [sol, "remote", "--json", "create", config.stream], 103 + capture_output=True, text=True, timeout=10, 104 + ) 105 + if result.returncode == 0: 106 + data = json.loads(result.stdout) 107 + config.key = data["key"] 108 + save_config(config) 109 + print(f"Registered (key: {config.key[:8]}...)") 110 + else: 111 + print(f"CLI registration failed, trying HTTP...") 112 + except (subprocess.TimeoutExpired, json.JSONDecodeError, KeyError, OSError): 113 + print("CLI registration failed, trying HTTP...") 114 + 115 + if not config.key: 116 + print("Registering with server...") 117 + client = UploadClient(config) 118 + if client.ensure_registered(config): 119 + config = load_config() 120 + print(f"Registered (key: {config.key[:8]}...)") 121 + else: 122 + print("Warning: registration failed. Run setup again when server is available.") 104 123 else: 105 124 print(f"Already registered (key: {config.key[:8]}...)") 106 125
+22 -1
src/solstone_linux/upload.py
··· 15 15 16 16 import json 17 17 import logging 18 + import shutil 19 + import subprocess 18 20 import time 19 21 from enum import Enum 20 22 from pathlib import Path ··· 70 72 def ensure_registered(self, config: Config) -> bool: 71 73 """Ensure the client has a valid key, auto-registering if needed. 72 74 75 + Tries sol CLI first (no server needed), falls back to HTTP. 73 76 Returns True if a key is available. 74 77 """ 75 78 if self._key: 76 79 return True 80 + 81 + # Try sol CLI registration first 82 + name = self._stream or "solstone-linux" 83 + sol = shutil.which("sol") 84 + if sol: 85 + try: 86 + result = subprocess.run( 87 + [sol, "remote", "--json", "create", name], 88 + capture_output=True, text=True, timeout=10, 89 + ) 90 + if result.returncode == 0: 91 + data = json.loads(result.stdout) 92 + self._key = data["key"] 93 + self._persist_key(config, self._key) 94 + logger.info(f"CLI-registered as '{name}' (key: {self._key[:8]}...)") 95 + return True 96 + except (subprocess.TimeoutExpired, json.JSONDecodeError, KeyError, OSError) as e: 97 + logger.debug(f"CLI registration failed: {e}") 98 + 77 99 if not self._url: 78 100 return False 79 101 80 102 url = f"{self._url}/app/remote/api/create" 81 - name = self._stream or "solstone-linux" 82 103 83 104 retries = min(3, len(self._retry_backoff)) 84 105 for attempt in range(retries):