MCPcopy Create free account
hub / github.com/FastLED/FastLED / install_usb_permissions

Method install_usb_permissions

ci/compiler/pio.py:1306–1367  ·  view source on GitHub ↗

Install platform-specific USB permissions (e.g., udev rules on Linux). Returns: True if installation succeeded, False otherwise

(self)

Source from the content-addressed store, hash-verified

1304 return has_access
1305
1306 def install_usb_permissions(self) -> bool:
1307 """Install platform-specific USB permissions (e.g., udev rules on Linux).
1308
1309 Returns:
1310 True if installation succeeded, False otherwise
1311 """
1312 import os
1313
1314 if platform.system() != "Linux":
1315 print("INFO: udev rules are only needed on Linux systems")
1316 return True
1317
1318 udev_url = "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules"
1319 udev_rules_path = "/etc/udev/rules.d/99-platformio-udev.rules"
1320
1321 print("📡 Downloading PlatformIO udev rules...")
1322
1323 try:
1324 # Download the udev rules
1325 with urllib.request.urlopen(udev_url) as response:
1326 udev_content = response.read().decode("utf-8")
1327
1328 # Write to temporary file first
1329 temp_file = "/tmp/99-platformio-udev.rules"
1330 with open(temp_file, "w") as f:
1331 f.write(udev_content)
1332
1333 print("💾 Installing udev rules (requires sudo)...")
1334
1335 # Use sudo to copy to system location
1336 result = RunningProcess.run(
1337 ["sudo", "cp", temp_file, udev_rules_path],
1338 cwd=None,
1339 check=False,
1340 timeout=10,
1341 )
1342
1343 if result.returncode != 0:
1344 print(f"ERROR: Failed to install udev rules: {result.stdout}")
1345 return False
1346
1347 # Clean up temp file
1348 os.unlink(temp_file)
1349
1350 print("✅ PlatformIO udev rules installed successfully!")
1351 print("⚠️ To complete the installation, run one of the following:")
1352 print(" sudo service udev restart")
1353 print(" # or")
1354 print(" sudo udevadm control --reload-rules")
1355 print(" sudo udevadm trigger")
1356 print(
1357 "⚠️ You may also need to restart your system for the changes to take effect."
1358 )
1359
1360 return True
1361
1362 except KeyboardInterrupt as ki:
1363 handle_keyboard_interrupt(ki)

Callers

nothing calls this directly

Calls 7

unlinkMethod · 0.80
printFunction · 0.50
decodeMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected