-
Notifications
You must be signed in to change notification settings - Fork 0
/
MachineManager.py
42 lines (34 loc) · 1.37 KB
/
MachineManager.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
import time, datetime
from Manager import Manager
class MachineManager(Manager):
def __init__(self):
super().__init__()
# def addMachine(self, machine):
# self.machineList.append(machine)
# def getMachine(self, i):
# return self.machineList[i - 1]
# def diffInTime(self, t1, t2):
# c = t2 - t1
# timeDiff = divmod(c.days * 86400 + c.seconds, 60)
# return timeDiff
def statusOfMachine (self, user, lastUpdated):
message = ""
machList = self.manageList
for x in range(len(machList)):
a = str(x + 1)
mach = self.getEntity(x + 1)
if not mach.isInUse():
message = message + a + " (" + mach.getType() + ")" + " is Available\n"
else:
message = message + a + " is Unavailable (Time used: " + str(self.diffInTime(mach.getTime(), datetime.datetime.now())[0]) + " minutes)\n"
message = message + "\n"
for i in range(len(machList)):
mach = self.getEntity(i + 1)
if mach.getUser() == user:
message = message + "Currently using: " + str(i+1) + "\n"
s2 = lastUpdated.strftime("%d/%m/%Y, %H:%M:%S")
message = message + "\n"
message = message + "Last Updated: " + s2
return message
# def getMachList(self):
# return self.machineList