-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreak_calculator.py
More file actions
75 lines (58 loc) · 2.31 KB
/
Copy pathbreak_calculator.py
File metadata and controls
75 lines (58 loc) · 2.31 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
import automate_it
import load_orders
import tkinter
class BreakCalculator():
def __init__(self, break_orders):
""" Calculate engineer break lengths and type of breaks.
Calculate engineer break length and type from a Hotel_Orders
db query.
Noteable Variables
------------------------------
break_orders - dictionary
sqlite DB query of all engineer break times in dict format.
engineer_list - list
List of engineers to verify. Helps in lowering time to calculate
order_list - list
List to save data for sorting algorithm.
"""
self.ait = automate_it.AutomateIt()
self.engineer_list = ['John Doe', 'Jane Doe']
order_list = []
for each in break_orders:
if each['Assigned'] not in self.engineer_list:
continue
self.ait.move_order_number()
self.ait.type_info(each['Order_Num'])
self.ait.type_info('enter')
try:
self.ait.find('screens/labor_tab_hot.png',
reg=(200, 685, 725, 345),
attempt_amount=15)
except self.automate_it.UnableToLocateError:
return False, 'Unable to locate.'
for com in ['tab', 'space', 'tab', 'tab', 'tab']:
self.ait.type_info(com)
automate_it.pyg.hotkey('ctrl', 'c')
break_length = tkinter.Tk().clipboard_get()
order_list.append(f"{each['Assigned']} took a {break_length} minute {each['Issue']}.")
self.ait.type_info('esc')
save_info(order_list.sort())
def save_info(self, values):
""" Save info to text file breaks.txt
Check if 'breaks.txt' exists, if it does not create file, if it does
append to end of file.
Noteable Variables
------------------------------
values - list
Iterable list to append to end of file.
"""
try:
f = open('breaks.txt', 'a')
except FileNotFoundError:
f = open('breaks.txt', 'w')
for each in values:
f.write(values)
if __name__ == '__main__':
lo = load_orders.HotOrders()
lo.update_orders()
bc = BreakCalculator(lo.all_orders_as_dict('Issue', 'Break - Casino Shop'))