The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(os): a Harness OS computer keeps the name `harness` (#1898)
Bubu-Dudu-52hz8bc4ba4251ed
diff --git a/os/setup.py b/os/setup.pyindex 901433933..ae3eb2a1d 100644--- a/os/setup.py+++ b/os/setup.py@@ -66,10 +66,6 @@ HOME = Path('/home') / USERSESSION = HOME / '.harness/auth/session.json'COMPUTER_ID = HOME / '.harness/computer-id'HOTSPOT = 'harness-setup'-HOSTNAME = Path('/etc/hostname')-HOSTS = Path('/etc/hosts')-# What the installer calls every computer (installer.py), until name_computer gives it its hotspot's name.-INSTALLED_NAME = 'harness'ADDRESS = '10.42.0.1'PORT = 80PROTOCOL = 1@@ -163,32 +159,6 @@ def hotspot_name(device=None):return 'Harness-' + (tail or 'Setup')-def name_computer(device=None):- """Call the computer what its hotspot is called (`Harness-BD19`) instead of the installer's- `harness`: every Harness OS was `harness`, so two in one account, on one router or in one Swarm- could not be told apart. Once, and only over that name: one somebody chose stays."""- try:- if HOSTNAME.read_text().strip() != INSTALLED_NAME:- return- except OSError:- return- name = hotspot_name(device)- try:- renamed = subprocess.run(['hostnamectl', 'set-hostname', name], capture_output=True, text=True, timeout=30)- except (OSError, subprocess.TimeoutExpired) as error:- log(f'could not name the computer {name}: {error}')- return- if renamed.returncode:- log(f'could not name the computer {name}: {renamed.stderr.strip()}')- return- try:- hosts = HOSTS.read_text()- HOSTS.write_text(re.sub(rf'^(127\.0\.1\.1\s+){INSTALLED_NAME}$', rf'\g<1>{name}', hosts, flags=re.M))- except OSError:- pass- log(f'named the computer {name}')--def signed_in():return SESSION.is_file()@@ -751,15 +721,9 @@ def set_up_as_unlocked():def watch():- started, waiting_since, named = time.monotonic(), None, False+ started, waiting_since = time.monotonic(), Nonewhile True:now = time.monotonic()- if not named:- # By the Wi-Fi card, as the hotspot is: once it is there, or once it would have been.- device = wifi_device()- if device or now - started >= DEVICE_WAIT:- name_computer(device)- named = Trueforced = asked_now()wait = 0 if forced else hotspot_wait(now, started)if wait is None:diff --git a/os/tests/test_setup.py b/os/tests/test_setup.pyindex 9c2139a78..8566023dc 100644--- a/os/tests/test_setup.py+++ b/os/tests/test_setup.py@@ -458,30 +458,6 @@ class Ssh(unittest.TestCase):'addresses': [{'interface': 'wlo1', 'address': '172.168.21.13'}]})-class Name(unittest.TestCase):- def name(self, hostname):- with tempfile.TemporaryDirectory() as folder:- etc = Path(folder)- (etc / 'hostname').write_text(hostname + '\n')- (etc / 'hosts').write_text(f'127.0.0.1 localhost\n::1 localhost\n127.0.1.1 {hostname}\n')- calls = []- with patch.object(setup, 'HOSTNAME', etc / 'hostname'), patch.object(setup, 'HOSTS', etc / 'hosts'), \- patch.object(setup, 'hotspot_name', return_value='Harness-BD19'), \- patch.object(setup.subprocess, 'run', side_effect=lambda command, **_: calls.append(command) or result()):- setup.name_computer('wlan0')- return calls, (etc / 'hosts').read_text()-- def test_the_installers_name_becomes_the_hotspots(self):- calls, hosts = self.name('harness')- self.assertEqual(calls, [['hostnamectl', 'set-hostname', 'Harness-BD19']])- self.assertIn('127.0.1.1 Harness-BD19\n', hosts)-- def test_a_name_somebody_chose_stays(self):- calls, hosts = self.name('studio')- self.assertEqual(calls, [])- self.assertIn('127.0.1.1 studio\n', hosts)--class InstallGh(unittest.TestCase):def install(self, present, *answers):"""install_gh with gh [present] or not, pacman exiting with each of [answers] in turn (0 puts gh there)."""