Skip to content

Commit

Permalink
Improve error log output
Browse files Browse the repository at this point in the history
  • Loading branch information
rbonghi committed Jan 8, 2024
1 parent c51b649 commit 8c42aee
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
21 changes: 19 additions & 2 deletions jtop/core/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from .command import Command
# Create logger
logger = logging.getLogger(__name__)

# default ipgu path for Jetson devices
DEFAULT_IGPU_PATH="/sys/class/devfreq/"

def check_nvidia_smi():
cmd = Command(['nvidia-smi'])
Expand Down Expand Up @@ -95,6 +96,22 @@ def igpu_read_status(path):
return gpu


def get_raw_igpu_devices():
igpu_path=DEFAULT_IGPU_PATH
raw_output = {}
for item in os.listdir(igpu_path):
item_path = os.path.join(igpu_path, item)
if os.path.isfile(item_path) or os.path.islink(item_path):
# Check name device
name_path = "{item}/device/of_node/name".format(item=item_path)
if os.path.isfile(name_path):
# Decode name
name = cat(name_path)
# path and file
raw_output[name_path] = "{}".format(name)
return raw_output


def find_igpu(igpu_path):
# Check if exist a integrated gpu
# if not os.path.exists("/dev/nvhost-gpu") and not os.path.exists("/dev/nvhost-power-gpu"):
Expand Down Expand Up @@ -260,7 +277,7 @@ class GPUService(object):

def __init__(self):
# Detect integrated GPU
igpu_path = "/sys/class/devfreq/"
igpu_path = DEFAULT_IGPU_PATH
if os.getenv('JTOP_TESTING', False):
igpu_path = "/fake_sys/class/devfreq/"
logger.warning("Running in JTOP_TESTING folder={root_dir}".format(root_dir=igpu_path))
Expand Down
2 changes: 1 addition & 1 deletion jtop/core/jetson_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def read_i2c_raw_data(bus, registry, size_block):
return string_data


def get_raw_output():
def get_jetson_raw_output():
raw_output = {}
# Catch all output from all files
for file in RAW_FILES:
Expand Down
19 changes: 13 additions & 6 deletions jtop/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

from copy import deepcopy
# jtop variable
from .core.gpu import get_raw_igpu_devices
from .core.hardware import get_platform_variables
from .core.jetson_variables import get_raw_output
from .core.jetson_variables import get_jetson_raw_output
from .terminal_colors import bcolors


Expand Down Expand Up @@ -79,12 +80,18 @@ def get_hardware_log():
body = "--------------------- PLATFORM -------------------------\n"
for name, value in platform.items():
body += "{name}: {value}\n".format(name=name, value=value)
# Print all raw output
raw_output = get_raw_output()
body += "-------------------- RAW OUTPUT ------------------------"
# Print all jetson raw output
raw_output = get_jetson_raw_output()
body += "-------------------- JETSON RAW OUTPUT -----------------\n"
for name, value in raw_output.items():
body += "\n------------------\n"
body += "{name}:\n{value}".format(name=name, value=value)
body += "------------------\n"
body += "Path: {name}\n{value}\n".format(name=name, value=value)
# Print device list
raw_output = get_raw_igpu_devices()
body += "\n-------------------- IGPU OUTPUT ---------------------\n"
for path, value in raw_output.items():
body += "------------------\n"
body += "Path: {path}\n{value}\n".format(path=path, value=value)
return body


Expand Down

0 comments on commit 8c42aee

Please sign in to comment.