-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.py
More file actions
280 lines (221 loc) · 8.75 KB
/
home.py
File metadata and controls
280 lines (221 loc) · 8.75 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
import subprocess
from subprocess import call
#Execute code from here
def Home() :
#Introductory message allowing user to choose from the different subgroups of operating system management
#This function returns an integer from 1-6
print(" --------------------------- WELCOME TO OPERATING SYSTEM MANAGEMENT ---------------------------")
print(" ")
print("PLEASE CHOOSE A SUBGROUP")
print(" ")
print("[1] USER AND GROUP MANAGEMENT")
print("[2] FILE MANAGEMENT")
print("[3] RESOURCE MONITORING")
print("[4] PROCESS MANAGEMENT")
print("[5] BACKUP AND RECOVERY")
print("[6] PERFORMANCE REPORTING")
print(" ")
while True:
valid = [1,2,3,4,5,6]
print("Please choose an integer from range 1-6 corresponding to your choice.")
answer = int(input("Enter the integer: "))
if answer in valid:
print(" ")
else:
print("Not valid.")
if answer ==1:
UserAndGroupManagement()
if answer ==2:
FileManagement()
if answer ==3:
resourceMonitoring()
if answer == 4:
processManagement()
if answer == 5:
backupAndRecovery()
if answer == 6:
performanceMonitoring()
print("-------------------------------------------------------------------------------------------------")
return answer
class userAndGroupManagement():
def addUser(self):
call("./addUser.sh", shell =True)
def deleteUser(self):
call("./deleteUser.sh", shell = True)
return
def addGroup(self):
call("./addGroup.sh", shell = True)
return
def deleteGroup(self):
call("./deleteGroup.sh", shell = True)
return
def addUserToGroup(self):
call("./addUserToGroup.sh", shell = True)
return
def removeUserFromGroup(self):
call("./removeUserFromGroup.sh", shell = True)
return
def assignGroup(self):
call("./assignGroup.sh", shell = True)
return
class fileManagement():
def createFile(self):
call("./createFile.sh", shell = True)
return
def createFileInPath(self):
call("./createfileInPath.sh", shell = True)
return
def deleteFile(self):
call("./deleteFile.sh", shell = True)
return
def encryptFile(self):
call("./encryptFile.sh", shell = True)
return
class ResourceMonitoring():
def monitorMemory():
call("./monitorMemory.sh", shell = True)
return
def monitorDisk():
call("./monitorDisk.sh", shell = True)
return
def monitorFreeMemory():
call("./monitorFreeMemory.sh", shell = True)
class ProcessManagement():
def sortMemoryUsage(self):
call("./sortMemoryUsage.sh", shell = True)
return
def sortCPUusage(self):
call("./sortCPUusage.sh", shell = True)
return
def terminateProcess(self):
call("./terminateProcess.sh", shell = True)
return
class BackupAndRecovery():
def performBackup():
call("./backup.sh", shell = True)
return
class PerformanceReporting() :
def generatePerformanceReport():
call("./generatePerformanceReport.sh", shell = True)
return
def UserAndGroupManagement():
print('-------------------- USER AND GROUP MANAGEMENT -----------------------')
print(" ")
print("Select a specific task: ")
print(" [1] ADD USER - add a user into the linux system (with password) ")
print(" [2] DELETE USER - delete user from from the linux system")
print(" [3] ADD GROUP - Create a new group inside the linux system (with GroupID)")
print(" [4] ADD USER TO GROUP - add user to an existing group")
print(" [5] REMOVE USER FROM GROUP - remove a member of an existing group")
print(" [6] ASSIGN GROUP - Assign ownership of a file/directory ")
print(" ")
print("Please select an integer from range 1-6.")
answer = int(input("Enter your chosen integer: "))
valid = [1,2,3,4,5,6]
if answer in valid:
print(" ")
else:
print("This is an invalid choice.")
session = userAndGroupManagement()
if answer == 1:
session.addUser()
else:
print(" ")
if answer == 2:
session.deleteUser()
if answer == 3:
session.addGroup()
if answer == 4:
session.addUserToGroup()
if answer == 5:
session.removeUserFromGroup()
if answer == 6:
session.assignGroup()
def FileManagement() :
print("--------------------------- FILE MANAGEMENT -------------------------")
print(" ")
print(" Please select a task below.")
print(" ")
print("[1] CREATE FILE - create a file within current directory")
print("[2] CREATE FILE IN PATH - create a file not in the current directory")
print("[3] DELETE FILE - delete a file within current directory")
print("[4] ENCRYPT FILE - encrypt a file ")
print(" ")
print("Select an integer from range 1-4")
answer = int(input("Enter a valid integer: "))
valid = [1,2,3,4]
if answer in valid:
print(" ")
session = fileManagement()
else:
print("This is not a valid choice.")
if answer == 1:
session.createFile()
if answer == 2:
session.createFileInPath()
if answer == 3:
session.deleteFile()
if answer == 4:
session.encryptFile()
def processManagement():
print("------------------------ Process Management --------------------------")
print(" ")
print(" Select an option below")
print("[1] IDENTIFY HIGH CPU CONSUMING PROCESSES - get information about processes that consume above average CPU resources ")
print("[2] IDENTIFY HIGH MEMORY CONSUMING PROCESSES - get inforamtion about processes that consume above average memory resources ")
print("[3] TERMINATE PROCESS - terminate a selected process from PID (process id) ")
print(" ")
print("Choose an integer from range 1-2")
answer = int(input('Enter chosen integer: '))
valid = [1,2,3]
if answer in valid:
session = ProcessManagement()
else:
print("This is not a valid choice/integer.")
if answer == 1:
session.sortCPUusage()
if answer ==2:
session.sortMemoryUsage()
if answer == 3:
session.terminateProcess()
def performanceMonitoring():
print("----------------- PERFORMANCE MONITORING----------------------")
print(" ")
print(" [1] Generate Performance Report - this script generates performance reports of teh linux system and device.")
answer= int(input("Press 1 to continue: "))
if answer == 1:
session = PerformanceReporting()
session.generatePerformanceReport(
)
else:
print("This is not a valid answer.")
def backupAndRecovery():
print("---------------------- BACKUP AND RECOVERY ----------------------")
print(" ")
print( "[1] PERFORM SYSTEM BACKUP - this functionality performacne a system backup")
answer = int(input( "PRess 1 to continue: "))
if answer == 1:
session = PerformanceReporting()
session.generatePerformanceReport()
else:
print ('This is not a valid answer.')
def resourceMonitoring():
#returns pdf files for user
print("------------------------- RESOURCE MONITORING ------------------------")
print(" ")
print("[1] MONITOR MEMORY - shows Memory statistics")
print("[2] MONITOR DISK - shows Disk statistics")
print("[3] MONITOR FREE MEMORY - shows available memory storage")
answer =int(input("Enter and Integer: "))
valid = [1,2,3]
if answer in valid:
session = ResourceMonitoring()
else:
print("This answer is not valid")
if answer == 1:
session.monitorCPU()
if answer == 2:
session.monitorDisk()
if answer ==3:
session.monitorFreeMemory()
Home()