-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRaspberry.py
52 lines (44 loc) · 1.21 KB
/
Raspberry.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import subprocess
class Raspberry:
@staticmethod
def Call(command):
time = subprocess.Popen(str(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = time.communicate();
return [output,err];
@staticmethod
def GetDate():
return Raspberry.Call('date')[0];
@staticmethod
def Reboot():
return Raspberry.Call('reboot');
@staticmethod
def PowerOff():
return Raspberry.Call('poweroff');
@staticmethod
def GetCPUInfo():
return Raspberry.Call('lscpu')[0];
@staticmethod
def GetDiscInfo():
return Raspberry.Call('lsblk')[0];
@staticmethod
def GetDiscSpaceInfo():
return Raspberry.Call('fdisk -l')[0];
@staticmethod
def GetUSBInfo():
return Raspberry.Call('lsusb')[0];
@staticmethod
def GetProcessInfo():
return Raspberry.Call('sudo ps -a')[0];
@staticmethod
def GetSystemInfo():
return Raspberry.Call('top')[0];
@staticmethod
def KillProcessByID(pid):
return Raspberry.Call('kill '+str(pid));
@staticmethod
def KillProcessByName(processName,killAll=False):
if killAll:
resp= Raspberry.Call('killall '+str(processName));
else:
resp= Raspberry.Call('pkill '+str(processName));
return resp;