Skip to content

Commit eb679e4

Browse files
authored
Merge pull request #2 from epifanio/master
python3 porting
2 parents 2260bfd + 7085629 commit eb679e4

1 file changed

Lines changed: 19 additions & 17 deletions

File tree

jetsonInfo.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
# MIT License
44
# Copyright (c) 2017-2018 Jetsonhacks
55
# Please see accompanying license information
6-
6+
from __future__ import print_function
77
import os,sys
88

9+
10+
911
class terminalColors:
1012
WARNING = '\033[93m'
1113
FAIL = '\033[91m'
@@ -25,11 +27,11 @@ class terminalColors:
2527
proc.communicate()
2628

2729
# Jetson Model
28-
print " NVIDIA Jetson " + os.environ["JETSON_BOARD"].strip()
30+
print(" NVIDIA Jetson " + os.environ["JETSON_BOARD"].strip())
2931

3032
#L4T Version
3133
if os.path.exists('/etc/nv_tegra_release'):
32-
with open("/etc/nv_tegra_release","r") as l4tVersionFile:
34+
with open('/etc/nv_tegra_release','r') as l4tVersionFile:
3335
l4tVersionFileText=l4tVersionFile.read()
3436
textLines=l4tVersionFileText.splitlines()
3537
l4tVersionInfo=textLines[0].split(',')
@@ -44,35 +46,35 @@ class terminalColors:
4446
elif 'BOARD' in entry:
4547
# Example: 'BOARD: t210ref'
4648
board=entry.split(' ')[2]
47-
print ' L4T ' + l4tRelease + '.' + l4tRevision + " [ JetPack " +os.environ["JETSON_JETPACK"].strip()+" ]"
48-
print ' Board: ' + board
49+
print(' L4T ' + l4tRelease + '.' + l4tRevision + ' [ JetPack ' +os.environ['JETSON_JETPACK'].strip()+' ]')
50+
print(' Board: ' + board)
4951
else:
50-
print terminalColors.FAIL + "Error: Unable to find L4T Version" + terminalColors.ENDC
51-
print "Reason: Unable to find file /etc/nv_tegra_release"
52+
print(terminalColors.FAIL + 'Error: Unable to find L4T Version' + terminalColors.ENDC)
53+
print('Reason: Unable to find file /etc/nv_tegra_release')
5254

5355
# Ubuntu version
5456
if os.path.exists('/etc/os-release'):
55-
with open("/etc/os-release","r") as ubuntuVersionFile:
57+
with open('/etc/os-release', 'r') as ubuntuVersionFile:
5658
ubuntuVersionFileText=ubuntuVersionFile.read()
5759
for line in ubuntuVersionFileText.splitlines():
5860
if 'PRETTY_NAME' in line:
5961
# PRETTY_NAME="Ubuntu 16.04 LTS"
6062
ubuntuRelease=line.split('"')[1]
61-
print ' ' + ubuntuRelease
63+
print(' ' + ubuntuRelease)
6264
else:
63-
print terminalColors.FAIL + "Error: Unable to find Ubuntu Version" + terminalColors.ENDC
64-
print "Reason: Unable to find file /etc/os-release"
65+
print(terminalColors.FAIL + 'Error: Unable to find Ubuntu Version' + terminalColors.ENDC)
66+
print('Reason: Unable to find file /etc/os-release')
6567

6668

6769

6870
# Kernel Release
6971
if os.path.exists('/proc/version'):
70-
with open("/proc/version","r") as versionFile:
72+
with open('/proc/version', 'r') as versionFile:
7173
versionFileText=versionFile.read()
72-
kernelReleaseArray=versionFileText.split(" ")
73-
print " Kernel Version: " + kernelReleaseArray[2]
74+
kernelReleaseArray=versionFileText.split(' ')
75+
print(' Kernel Version: ' + kernelReleaseArray[2])
7476
else:
75-
print terminalColors.FAIL + "Error: Unable to find Linux kernel version" + terminalColors.ENDC
76-
print "Reason: Unable to find file /proc/version"
77+
print(terminalColors.FAIL + 'Error: Unable to find Linux kernel version' + terminalColors.ENDC)
78+
print('Reason: Unable to find file /proc/version')
7779

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

0 commit comments

Comments
 (0)