Skip to content

Commit

Permalink
Merge pull request #2 from epifanio/master
Browse files Browse the repository at this point in the history
python3 porting
  • Loading branch information
jetsonhacks authored Nov 10, 2018
2 parents 2260bfd + 7085629 commit eb679e4
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions jetsonInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
# MIT License
# Copyright (c) 2017-2018 Jetsonhacks
# Please see accompanying license information

from __future__ import print_function
import os,sys



class terminalColors:
WARNING = '\033[93m'
FAIL = '\033[91m'
Expand All @@ -25,11 +27,11 @@ class terminalColors:
proc.communicate()

# Jetson Model
print " NVIDIA Jetson " + os.environ["JETSON_BOARD"].strip()
print(" NVIDIA Jetson " + os.environ["JETSON_BOARD"].strip())

#L4T Version
if os.path.exists('/etc/nv_tegra_release'):
with open("/etc/nv_tegra_release","r") as l4tVersionFile:
with open('/etc/nv_tegra_release','r') as l4tVersionFile:
l4tVersionFileText=l4tVersionFile.read()
textLines=l4tVersionFileText.splitlines()
l4tVersionInfo=textLines[0].split(',')
Expand All @@ -44,35 +46,35 @@ class terminalColors:
elif 'BOARD' in entry:
# Example: 'BOARD: t210ref'
board=entry.split(' ')[2]
print ' L4T ' + l4tRelease + '.' + l4tRevision + " [ JetPack " +os.environ["JETSON_JETPACK"].strip()+" ]"
print ' Board: ' + board
print(' L4T ' + l4tRelease + '.' + l4tRevision + ' [ JetPack ' +os.environ['JETSON_JETPACK'].strip()+' ]')
print(' Board: ' + board)
else:
print terminalColors.FAIL + "Error: Unable to find L4T Version" + terminalColors.ENDC
print "Reason: Unable to find file /etc/nv_tegra_release"
print(terminalColors.FAIL + 'Error: Unable to find L4T Version' + terminalColors.ENDC)
print('Reason: Unable to find file /etc/nv_tegra_release')

# Ubuntu version
if os.path.exists('/etc/os-release'):
with open("/etc/os-release","r") as ubuntuVersionFile:
with open('/etc/os-release', 'r') as ubuntuVersionFile:
ubuntuVersionFileText=ubuntuVersionFile.read()
for line in ubuntuVersionFileText.splitlines():
if 'PRETTY_NAME' in line:
# PRETTY_NAME="Ubuntu 16.04 LTS"
ubuntuRelease=line.split('"')[1]
print ' ' + ubuntuRelease
print(' ' + ubuntuRelease)
else:
print terminalColors.FAIL + "Error: Unable to find Ubuntu Version" + terminalColors.ENDC
print "Reason: Unable to find file /etc/os-release"
print(terminalColors.FAIL + 'Error: Unable to find Ubuntu Version' + terminalColors.ENDC)
print('Reason: Unable to find file /etc/os-release')



# Kernel Release
if os.path.exists('/proc/version'):
with open("/proc/version","r") as versionFile:
with open('/proc/version', 'r') as versionFile:
versionFileText=versionFile.read()
kernelReleaseArray=versionFileText.split(" ")
print " Kernel Version: " + kernelReleaseArray[2]
kernelReleaseArray=versionFileText.split(' ')
print(' Kernel Version: ' + kernelReleaseArray[2])
else:
print terminalColors.FAIL + "Error: Unable to find Linux kernel version" + terminalColors.ENDC
print "Reason: Unable to find file /proc/version"
print(terminalColors.FAIL + 'Error: Unable to find Linux kernel version' + terminalColors.ENDC)
print('Reason: Unable to find file /proc/version')

print " CUDA " + os.environ["JETSON_CUDA"].strip()
print(' CUDA ' + os.environ['JETSON_CUDA'].strip())

0 comments on commit eb679e4

Please sign in to comment.