Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/no more sudo #67

Merged
merged 165 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
d785f7b
First service initialization
rbonghi Jun 10, 2020
b7fd1d6
Move service socket configuration
rbonghi Jun 10, 2020
673752a
clean starting service
rbonghi Jun 10, 2020
ddbb50f
change in a thread runner tegrastats class
rbonghi Jun 10, 2020
eaadc4a
System with BaseManager and queue works
rbonghi Jun 11, 2020
3de28c9
Clean and fix code
rbonghi Jun 11, 2020
820dd81
Improve tegrastats and services
rbonghi Jun 11, 2020
5e5116e
Move service in core
rbonghi Jun 11, 2020
07b601d
Clean and fix tox. Temporary disable tests files
rbonghi Jun 11, 2020
02f548f
Improve timeout service
rbonghi Jun 11, 2020
7903e20
Improve tegrastats
rbonghi Jun 11, 2020
a70bb35
Fix tox
rbonghi Jun 11, 2020
5b6cd02
Improve service
rbonghi Jun 11, 2020
1f74166
Rearrange service
rbonghi Jun 11, 2020
a030507
tegrastats controller
rbonghi Jun 12, 2020
0d42524
Fix dict conversion
rbonghi Jun 12, 2020
1f1f9b2
Remove some exposed methods
rbonghi Jun 12, 2020
64cc146
Convert from AutoProxy do dictionary
rbonghi Jun 12, 2020
25de00f
Improve tegrastats
rbonghi Jun 12, 2020
dfa153e
Fix tegrastats error and added lock
rbonghi Jun 12, 2020
d5b1587
Fix tox
rbonghi Jun 12, 2020
e182ac6
Fix python3 errors and added exceptions
rbonghi Jun 12, 2020
04711df
Alive message only if data is different
rbonghi Jun 12, 2020
998929e
Improve jtop service and client with condition
rbonghi Jun 13, 2020
e62790b
Improve service adding chmod and chown. Improve timeout
rbonghi Jun 13, 2020
36eccfe
Fix tox
rbonghi Jun 13, 2020
7799909
Add observer
rbonghi Jun 13, 2020
2c54536
Add new properties jtop
rbonghi Jun 13, 2020
3e2b834
Change jtop startup with start in second
rbonghi Jun 14, 2020
772a5eb
Improve jtop
rbonghi Jun 14, 2020
803464a
Clean functions with lambad
rbonghi Jun 14, 2020
6780288
Fix jetson_clocks without service
rbonghi Jun 14, 2020
a93797b
Merge branch 'feature/no_more_sudo' of github.com:rbonghi/jetson_stat…
rbonghi Jun 14, 2020
cdf4966
Remove old services and fix tox
rbonghi Jun 14, 2020
cd08ba3
Fix servicer from condition to event
rbonghi Jun 14, 2020
e4cb148
Fix raise exception from raise thread
rbonghi Jun 14, 2020
a632ca5
add gpu and other new properties
rbonghi Jun 14, 2020
7903a8d
Add Keyboard interrupt event
rbonghi Jun 14, 2020
78fb294
Fix raise exception
rbonghi Jun 14, 2020
e965d8a
Improve Exception
rbonghi Jun 14, 2020
4bc380d
Improve manage exception by client
rbonghi Jun 15, 2020
9973cc7
Improve server exception
rbonghi Jun 15, 2020
c193c06
Improve exception control
rbonghi Jun 15, 2020
3704319
Improve main
rbonghi Jun 15, 2020
5fd0c7a
Improve jetson_clocks class and startup
rbonghi Jun 15, 2020
c773d1d
Improve jtop and jetson_clocks
rbonghi Jun 15, 2020
82d6a2b
Improve jtop and service
rbonghi Jun 15, 2020
b628c05
Improve jetson_clocks and service
rbonghi Jun 16, 2020
a54f857
Add configuration object. Add jetson_clocks reader
rbonghi Jun 16, 2020
80d1202
Improve config and jetson_clocks
rbonghi Jun 16, 2020
016d8c2
Update jetson_variables
rbonghi Jun 16, 2020
e2fe264
Add general jtop exception. Improve nvpmodel
rbonghi Jun 17, 2020
891b33b
Improve nvpmodel
rbonghi Jun 17, 2020
2efb01f
Merge branch 'feature/no_more_sudo' of github.com:rbonghi/jetson_stat…
rbonghi Jun 17, 2020
fc22912
Fix jtop_socket and add references
rbonghi Jun 17, 2020
2a4119d
Improve nvpmodel and add jetson_stats.py service
rbonghi Jun 18, 2020
299867c
Improve jetson_clocks sender
rbonghi Jun 18, 2020
39abf62
Fix jetson_clocks configuration
rbonghi Jun 18, 2020
9eb9abc
Add fan controller
rbonghi Jun 18, 2020
1f55ae4
Refactoring Fan controller
rbonghi Jun 18, 2020
a6912fd
Improve fan
rbonghi Jun 18, 2020
200fba2
Minor fixes
rbonghi Jun 18, 2020
78d0844
Improve fan controller
rbonghi Jun 19, 2020
e8ff975
Fix fan controller #41
rbonghi Jun 19, 2020
b4cb767
Fix tox
rbonghi Jun 19, 2020
ff82b13
Fix jtop for system without fan
rbonghi Jun 19, 2020
267b72c
Improve jetson_clocks with close thread
rbonghi Jun 20, 2020
ee4a2a8
Speed up jetson_clock_show
rbonghi Jun 20, 2020
de7eb47
Improve start up jetson_clocks
rbonghi Jun 20, 2020
8ec5690
Improve start up service
rbonghi Jun 20, 2020
2119fcf
Improve jtop with new swap manager
rbonghi Jun 20, 2020
0bba20f
Fix flaxe8
rbonghi Jun 20, 2020
fec066e
Make new file memory and improve swap manager
rbonghi Jun 20, 2020
e11785c
Fix flaxe8
rbonghi Jun 20, 2020
9fd8db4
Improve Swap and jetson_variable startup
rbonghi Jun 21, 2020
7e500ac
Fix startup swap
rbonghi Jun 21, 2020
8c9bb40
Fix swap initialization
rbonghi Jun 22, 2020
451e09a
Fix jetson_clocks test
rbonghi Jun 22, 2020
dac0390
Improve with internal event
rbonghi Jun 22, 2020
c7b5744
Improve jtop and fix error trace. First rearrange GUI
rbonghi Jun 22, 2020
edf630a
Improve exception interceptor
rbonghi Jun 23, 2020
e287aa6
Fix communication error
rbonghi Jun 23, 2020
653e36b
Improve tegrastats
rbonghi Jun 23, 2020
245cde8
Add new jtop options
rbonghi Jun 24, 2020
c80cf40
Fix page info and improve page all with new library definitions
rbonghi Jun 24, 2020
afe9d6e
Fix pages without refresh information
rbonghi Jun 24, 2020
df9e495
Rearrange jetson_clocks
rbonghi Jun 24, 2020
6fc633f
Clean and improve jtop gui
rbonghi Jun 25, 2020
9b6e975
Merge branch 'feature/no_more_sudo' of github.com:rbonghi/jetson_stat…
rbonghi Jun 25, 2020
34a838f
Fix refresh rate GUI
rbonghi Jun 25, 2020
ffb8053
Improve gui with new library definitions
rbonghi Jun 26, 2020
91bb24a
Fix tox
rbonghi Jun 26, 2020
790ab66
Move service in main
rbonghi Jun 26, 2020
6255615
Improve jetson_stats service installer
rbonghi Jun 26, 2020
a2254b9
Update and clean jetson_config
rbonghi Jun 26, 2020
7835e7b
Improve jetson_server startup
rbonghi Jun 26, 2020
6f28e4f
Improve and fix for python3
rbonghi Jun 26, 2020
00b590a
Fix tox
rbonghi Jun 26, 2020
f6cc4ca
Fix measure total power
rbonghi Jun 26, 2020
49792a0
Improve control page with new library information
rbonghi Jun 27, 2020
954cebf
Improve control fan and nvpmodel
rbonghi Jun 27, 2020
a7fd891
Fix configurations and variables
rbonghi Jun 27, 2020
65fe38a
Fix CPU and mem page
rbonghi Jun 28, 2020
11b36f2
Improve swap and memory controller
rbonghi Jun 28, 2020
5370b91
Fix tox
rbonghi Jun 28, 2020
b73a38e
Reconfigure pytests
rbonghi Jun 29, 2020
f426934
Fix group in actions github
rbonghi Jun 29, 2020
1364808
Fix different versions
rbonghi Jun 29, 2020
f6a90e5
Improve workflow
rbonghi Jun 29, 2020
69be2f5
pass python version
rbonghi Jun 29, 2020
5b049f8
pass python version
rbonghi Jun 29, 2020
ee397d4
Test try pass envs to sudo
rbonghi Jun 29, 2020
7af03ab
Test try pass envs to sudo
rbonghi Jun 29, 2020
2d4c3ab
Test try pass envs to sudo
rbonghi Jun 29, 2020
92f011c
Test try pass envs to sudo
rbonghi Jun 29, 2020
f9867be
Test try pass envs to sudo
rbonghi Jun 29, 2020
3b15564
Test try pass envs to sudo
rbonghi Jun 29, 2020
7734d52
Test try pass envs to sudo
rbonghi Jun 29, 2020
a53b040
Test try pass envs to sudo
rbonghi Jun 29, 2020
b89fa2a
Test try pass envs to sudo
rbonghi Jun 29, 2020
90ebe33
Add jetson_clocks tests
rbonghi Jun 29, 2020
cd64560
Add test GUI and jtop with callback
rbonghi Jun 29, 2020
1b73c63
Add test nvpmodel
rbonghi Jun 29, 2020
9af0402
Test on package
rbonghi Jun 29, 2020
c3d087e
Split jetson_variables in jetson_libraries. Now jtop wait jetson_vari…
rbonghi Jun 30, 2020
de8212b
Fix service start
rbonghi Jun 30, 2020
163a1cb
Fix jetson_release
rbonghi Jun 30, 2020
eb67a31
Change initialization peripherals
rbonghi Jul 1, 2020
ce230d4
Move CPU model read to service read
rbonghi Jul 1, 2020
949785b
Read CPU info
rbonghi Jul 1, 2020
58beeb2
Fix gui pages
rbonghi Jul 1, 2020
1e841fc
Add memory controller
rbonghi Jul 1, 2020
f774f27
Fix memory controller
rbonghi Jul 1, 2020
b22c616
Rearrange path folders
rbonghi Jul 1, 2020
9e10cd7
fix tox
rbonghi Jul 1, 2020
4699944
fix open and close service
rbonghi Jul 2, 2020
3656e3b
Fix service close and tegrastats control
rbonghi Jul 2, 2020
f052542
Add Fan test
rbonghi Jul 2, 2020
647963d
Add test service and improve other tests
rbonghi Jul 2, 2020
f775d47
Improve tests pytest
rbonghi Jul 2, 2020
508bc0a
Improve jtop and fix tests
rbonghi Jul 3, 2020
204500a
Fix service
rbonghi Jul 3, 2020
c463603
Improve jetson_clocks with timeout
rbonghi Jul 4, 2020
4896002
Fix store function
rbonghi Jul 4, 2020
d33bc0b
Fix tox
rbonghi Jul 4, 2020
9cbf4c4
Improve tests
rbonghi Jul 4, 2020
042e4d2
Improve test and add new methods
rbonghi Jul 5, 2020
922fc31
Rearrange decoding messages from service
rbonghi Jul 5, 2020
2c573b1
Improve jtop and fix major bugs
rbonghi Jul 5, 2020
a52caa2
Add check storing jetson_clocks configuration
rbonghi Jul 5, 2020
534a15a
Fix nvpmodel control
rbonghi Jul 5, 2020
a47b8fb
Improve nvpmodel control
rbonghi Jul 5, 2020
eb1e57b
Fix catch exception startup
rbonghi Jul 5, 2020
0a54bb3
Fix ConnectionRefusedError for python 2.7
rbonghi Jul 5, 2020
0aa09fc
Fix name fan mode
rbonghi Jul 6, 2020
9bc2f41
Improve examples and fix jetson.stats
rbonghi Jul 6, 2020
af11da1
Improve jetson-stats service
rbonghi Jul 6, 2020
3276b1f
Improve fan controller and fix socket file
rbonghi Jul 7, 2020
dc4cdd9
Fix test fan
rbonghi Jul 8, 2020
011901f
Fix permissions exception
rbonghi Jul 8, 2020
6badd32
Fix PermissionError for python 2.7 and fix Fan controller
rbonghi Jul 8, 2020
8513a2f
Fix check nvpmodel after jetson_clocks and improve service
rbonghi Jul 9, 2020
956493f
Fix jetson.stats out
rbonghi Jul 9, 2020
47660a8
Fix imports
rbonghi Jul 9, 2020
771597f
Fix uptime in test
rbonghi Jul 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
# Make group jetson_stats
sudo groupadd jetson_stats
# Install test dependencies
sudo ./tests/develop.sh -s
# Upgrade pip
python -m pip install --upgrade pip
sudo -H python -m pip install --upgrade pip
# Install tox
sudo apt-get install tox
sudo -H pip install tox
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Test with tox
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
with:
persist-credentials: false

- name: Install jtop
run: python setup.py install
- name: Sphinx Build
# Follow: https://github.com/marketplace/actions/sphinx-build
uses: ammaraskar/sphinx-action@0.3
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ venv/
.cache/
swapfile
test.*
*.csv

.vscode/
.vscode/
.venv*/
3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
import os
import sys
import jtop
sys.path.insert(0, os.path.abspath('../../'))

# -- Project information -----------------------------------------------------
Expand All @@ -24,7 +25,7 @@
author = 'Raffaello Bonghi'

# The full version, including alpha/beta/rc tags
release = '1.8.0'
release = jtop.__version__

# -- General configuration ---------------------------------------------------

Expand Down
20 changes: 13 additions & 7 deletions examples/jtop_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,30 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from jtop import jtop
from jtop import jtop, JtopException


def read_stats(stats):
def read_stats(jetson):
"""
This is your callback function where you can read all files when are availables.
"""
print(stats)
print(jetson.stats)


if __name__ == "__main__":
print("Initialize jtop")
print("Initialize jtop callback")
# Open the jtop
jetson = jtop()
# Attach a function where you can read the status of your jetson
jetson.attach(read_stats)

# Nothing to do, now you can read
while True:
pass
# This try excpet will catch jtop exception
try:
# This loop will manage the jtop status all the time
# This is a blocking a function, if you do not want use you can use as well
# start: jetson.start()
# stop: jetson.stop()
jetson.loop_for_ever()
except JtopException as e:
print(e)
# EOF
68 changes: 68 additions & 0 deletions examples/jtop_control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# This file is part of the jetson_stats package (https://github.com/rbonghi/jetson_stats or http://rnext.it).
# Copyright (c) 2019 Raffaello Bonghi.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from jtop import jtop, JtopException

if __name__ == "__main__":

print("Simple jtop controller")

try:
# All options are not blocking
with jtop() as jetson:
# Read jetson_clocks status
print(jetson.jetson_clocks)
# Set a new status
jetson.jetson_clocks = True
# Read nvpmodel
if jetson.nvpmodel:
# Read nvpmodel
print(jetson.nvpmodel)
# Set new state
jetson.nvpmodel = 0 # You can write the name of the model as well
# Wait nvpmodel changed
while jetson.ok():
if jetson.nvpmodel.id == 0:
break
# You can increase or decrease the nvpmodel using
jetson.nvpmodel += 1 # or jetson.nvpmodel = jetson.nvpmodel + 1
# Wait nvpmodel changed
while jetson.ok():
if jetson.nvpmodel.id == 1:
break
# You can control the fan
if jetson.fan:
# read fan status
print(jetson.fan)
# You can change mode and setting
jetson.fan.mode = 'system'
# Wait nvpmodel changed
while jetson.ok():
if jetson.fan.mode == 'system':
break
# Or you can change the fan speed
jetson.fan.speed = 100
while jetson.ok():
# Print jetson fan status
print(jetson.fan)
# Leave when fan measure is at 100%
if jetson.fan.measure == 100:
break
except JtopException as e:
print(e)
# EOF
56 changes: 56 additions & 0 deletions examples/jtop_logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# This file is part of the jetson_stats package (https://github.com/rbonghi/jetson_stats or http://rnext.it).
# Copyright (c) 2019 Raffaello Bonghi.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from jtop import jtop, JtopException
import csv
import argparse


if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Simple jtop logger')
# Standard file to store the logs
parser.add_argument('--file', action="store", dest="file", default="log.csv")
args = parser.parse_args()

print("Simple jtop logger")
print("Saving log on {file}".format(file=args.file))

try:
with jtop() as jetson:
# Make csv file and setup csv
with open(args.file, 'w') as csvfile:
stats = jetson.stats
# Initialize cws writer
writer = csv.DictWriter(csvfile, fieldnames=stats.keys())
# Write header
writer.writeheader()
# Write first row
writer.writerow(stats)
# Start loop
while jetson.ok():
stats = jetson.stats
# Write row
writer.writerow(stats)
print("Log at {time}".format(time=stats['time']))
except JtopException as e:
print(e)
except KeyboardInterrupt:
print("Closed with CTRL-C")
except IOError:
print("I/O error")
# EOF
20 changes: 12 additions & 8 deletions examples/jtop_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.


from jtop import jtop
from jtop import jtop, JtopException
import socket
import json
import argparse

parser = argparse.ArgumentParser(description='Simple Tegrastats server.')
parser = argparse.ArgumentParser(description='Simple jtop server.')

# Standard loopback interface address (localhost)
parser.add_argument('--host', action="store", dest="host", default="127.0.0.1")
Expand All @@ -37,16 +37,16 @@

if __name__ == "__main__":

print("Simple Tegrastats server")
print("Simple jtop server")

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((args.host, args.port))
print("Open server jtop to {}:{}".format(args.host, args.port))
sock.listen(1)

with jtop() as jetson:
try:
while True:
try:
with jtop() as jetson:
while jetson.ok():
# Wait socket request
conn, addr = sock.accept()
print("Connected to {}".format(conn))
Expand All @@ -60,6 +60,10 @@
conn.send(stats.encode())
# Close connection
conn.close()
except Exception:
sock.close()
except JtopException as e:
print(e)
except Exception as e:
print(e)
finally:
sock.close()
# EOF
81 changes: 0 additions & 81 deletions examples/log_data.py

This file was deleted.

18 changes: 9 additions & 9 deletions examples/quick_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from jtop import jtop
import time


if __name__ == "__main__":

print("Simple Tegrastats reader")
print("Simple jtop reader")

with jtop() as jetson:
while True:
# jetson.ok() will provide the proper update frequency
while jetson.ok():
# Read tegra stats
print(jetson.stats)
# nvpmodel
print(jetson.nvpmodel)
# jetson_clocks
print(jetson.jetson_clocks)
# Status disk
print(jetson.disk)
# Status fans
if hasattr(jetson, 'fan'):
print(jetson.fan)
print(jetson.fan)
# uptime
print(jetson.uptime)
# nvpmodel
print(jetson.nvpmodel)
# local interfaces
print(jetson.local_interfaces)
# boards
print(jetson.board)
# Sleep before send new stat
time.sleep(1)
# EOF