-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhelpers.py
59 lines (45 loc) · 1.54 KB
/
helpers.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
53
54
55
56
57
58
59
import json
from qtpy.QtWidgets import QMessageBox
import sql as Connection
def secondsToText(secs):
days = secs//86400
hours = (secs - days*86400)//3600
minutes = (secs - days*86400 - hours*3600)//60
seconds = secs - days*86400 - hours*3600 - minutes*60
result = ("{} da, ".format(days) if days else "") + \
("{} h, ".format(hours) if hours else "") + \
("{} m, ".format(minutes) if minutes else "") + \
("{} s ".format(seconds) if seconds else "")
return result
def showdialog(window_title, message):
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText(message)
# msg.setInformativeText("This is additional information")
msg.setWindowTitle(window_title)
# msg.setDetailedText("The details are as follows:")
msg.setStandardButtons(QMessageBox.Ok)
# msg.buttonClicked.connect(msgbtn)
msg.exec_()
def get_cells_capacity(capacities_dict):
cap_list = []
for cell in capacities_dict:
cap_list.append(round(cell["Capacity"], 2))
return cap_list
def calculate_pack(cells, s, p):
count = s * p
available = sorted(cells, key=lambda b: int(b['capacity']), reverse=True)[:count]
paralel_series = []
for i in range(s):
paralel_series.append([])
for j in range(p):
paralel_series[i].append(available[i + s * j])
pack = dict()
cell = 1
for par in paralel_series:
pack[cell] = []
for unit in par:
pack[cell].append(unit)
# print(unit)
cell += 1
return pack