Skip to content

Commit bed85bc

Browse files
committed
Update file name.
1 parent 5b2fc68 commit bed85bc

File tree

4 files changed

+102
-1
lines changed

4 files changed

+102
-1
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ General System Info
167167
General system info, including CPU, RAM, memory, etc. is retrieved via ``myDevices.os.systeminfo.py`` This is mostly implemented via a C library for the Raspberry Pi, though that will be changed to a Python only implementation in the future. If the C library doesn't work on your device you can disable the C library call until the Python implementation is available at which point you can modify it to support your board.
168168

169169
Hardware Info
170-
Hardware info, including make, model, etc. is retrieved via ``myDevices.cloud.vcom_id.py``. This should be modified or overridden to provide the appropriate hardware info for your board.
170+
Hardware info, including make, model, etc. is retrieved via ``myDevices.os.hardware.py``. This should be modified or overridden to provide the appropriate hardware info for your board.
171171

172172
Pin Mapping
173173
The mapping of the on-board pins is provided in ``myDevices.utils.version.py`` with the ``MAPPING`` list. This list provides the available GPIO pin numbers as well as the voltage ("V33", "V50"), ground ("GND") and do-not-connect ("DNC") pins. This should be updated with the mapping for your board. However, the Cayenne dashboard is currently built to display the Raspberry Pi GPIO layout so if your board's pin layout is significantly different it may not display correctly in the GPIO tab.

myDevices/test/processes_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import unittest
2+
from myDevices.os.services import ProcessManager
3+
4+
class ProcessesTest(unittest.TestCase):
5+
def testProcesses(self):
6+
processManager = ProcessManager()
7+
processManager.Run()
8+
print(processManager.GetProcessList())
9+
10+
if __name__ == '__main__':
11+
unittest.main()

myDevices/test/systeminfo_test.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import unittest
2+
from ctypes import CDLL, c_char_p
3+
from myDevices.os.systeminfo import SystemInfo
4+
from json import loads
5+
from myDevices.os.services import ProcessManager
6+
from myDevices.os.cpu import CpuInfo
7+
from time import sleep
8+
from myDevices.os.hardware import Hardware
9+
from myDevices.utils.logger import setInfo
10+
11+
from psutil import cpu_times, virtual_memory
12+
from myDevices.sensors import sensors
13+
14+
class SystemInfoTest(unittest.TestCase):
15+
def setUp(self):
16+
setInfo()
17+
libSystemInformation=CDLL("/etc/myDevices/libs/libSystemInformation.so")
18+
if libSystemInformation:
19+
libSystemInformation.GetSystemInformation.restype=c_char_p
20+
currentSystemInfo = libSystemInformation.GetSystemInformation().decode('utf-8')
21+
libSystemInformation.FreeSystemInformation()
22+
self.c_library_info = loads(currentSystemInfo)
23+
24+
def testSystemInfo(self):
25+
system_info = SystemInfo()
26+
info = loads(system_info.getSystemInformation())
27+
# print('info type {}, {}'.format(type(info), info))
28+
# info = loads(info)
29+
print(info.keys())
30+
# client = sensors.SensorsClient()
31+
# sys_info = client.SystemInformation()
32+
# print(sys_info['CpuLoad'])
33+
# client.StopMonitoring()
34+
cpu_info = info['Cpu']
35+
print(cpu_info)
36+
print(cpu_times())
37+
self.assertEqual(set(cpu_info.keys()), set(('loadavg', 'usage', 'temperature')))
38+
self.assertEqual(set(cpu_info['loadavg'].keys()), set(('one', 'five', 'ten')))
39+
self.assertEqual(set(cpu_info['usage'].keys()), set(('user', 'nice', 'system', 'idle', 'iowait', 'irq', 'softirq', 'total', 'busy')))
40+
memory_info = info['Memory']
41+
print(memory_info)
42+
self.assertEqual(set(memory_info.keys()), set(('total', 'free', 'used', 'buffers', 'cached', 'processes', 'swap')))
43+
self.assertEqual(set(memory_info['swap'].keys()), set(('total', 'free', 'used')))
44+
print(info['Uptime'])
45+
for key in info['Storage'].keys():
46+
print('{} : {}'.format(key, info['Storage'][key].keys()))
47+
print(info['Storage'].keys())
48+
print(info['Network'].keys())
49+
50+
# print(virtual_memory())
51+
52+
# def testSystemInfo(self):
53+
# hardware = Hardware()
54+
# print(hardware.getManufacturer())
55+
# print(hardware.getModel())
56+
# print(hardware.getMac())
57+
# info = loads(getSystemInformation())
58+
# print(info['Cpu'])
59+
# cpuLoad = GetCpuLoad()
60+
# print(cpuLoad.getcpuload())
61+
# processManager = ProcessManager()
62+
# data = {}
63+
# processManager.RefreshProcessManager()
64+
# data['VisibleMemory'] = processManager.VisibleMemory
65+
# data['AvailableMemory'] = processManager.AvailableMemory
66+
# data['AverageProcessorUsage'] = processManager.AverageProcessorUsage
67+
# data['PeakProcessorUsage'] = processManager.PeakProcessorUsage
68+
# data['AverageMemoryUsage'] = processManager.AverageMemoryUsage
69+
# data['PeakMemoryUsage'] = processManager.AverageMemoryUsage
70+
# data['PercentProcessorTime'] = processManager.PercentProcessorTime
71+
# print(data)
72+
# for i in range(10):
73+
# sleep(5)
74+
# print(cpuLoad.getcpuload())
75+
76+
77+
if __name__ == '__main__':
78+
unittest.main()

myDevices/test/user_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pwd
2+
import os
3+
4+
try:
5+
user = pwd.getpwnam('cayenne')
6+
user_id = user.pw_uid
7+
group_id = user.pw_gid
8+
except KeyError:
9+
user_id = os.environ['SUDO_UID']
10+
group_id = os.environ['SUDO_GID']
11+
print(user_id)
12+
print(group_id)

0 commit comments

Comments
 (0)