forked from OpenInterpreter/01
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OpenInterpreter#97 from tyfiero/Ubuntu-fix
Fix error on ubuntu machines
- Loading branch information
Showing
1 changed file
with
17 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,41 @@ | ||
import os | ||
import platform | ||
|
||
|
||
def get_system_info(): | ||
system = platform.system() | ||
|
||
if system == "Linux": | ||
# Attempt to identify specific Linux distribution | ||
distro = "linux" # Default to generic 'linux' | ||
try: | ||
with open("/etc/os-release") as f: | ||
os_release_info = f.read().lower() | ||
if "ubuntu" in os_release_info: | ||
return "raspberry-pi-ubuntu" | ||
elif "raspbian" in os_release_info: | ||
return "raspberry-pi-os" | ||
if "raspbian" in os_release_info: | ||
distro = "raspberry-pi-os" | ||
elif "ubuntu" in os_release_info: | ||
distro = "ubuntu" | ||
except FileNotFoundError: | ||
pass | ||
|
||
# Check for Raspberry Pi hardware | ||
is_raspberry_pi = False | ||
try: | ||
with open("/proc/device-tree/model") as f: | ||
model_info = f.read() | ||
if "Raspberry Pi" in model_info: | ||
if distro == "ubuntu": | ||
return "raspberry-pi-ubuntu" | ||
return "raspberry-pi" | ||
if "Raspberry Pi" in model_info: | ||
is_raspberry_pi = True | ||
except FileNotFoundError: | ||
pass | ||
|
||
return distro | ||
|
||
if is_raspberry_pi: | ||
if distro == "ubuntu": | ||
return "raspberry-pi-ubuntu" | ||
else: | ||
return "raspberry-pi" | ||
else: | ||
return distro | ||
elif system == "Darwin": | ||
return "darwin" | ||
elif system == "Windows": | ||
return "windows" | ||
else: | ||
return "unknown" | ||
return "unknown" |