itkdb-gtk 0.10.9.dev3__py3-none-any.whl → 0.10.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of itkdb-gtk might be problematic. Click here for more details.

itkdb_gtk/readAVSdata.py DELETED
@@ -1,693 +0,0 @@
1
- #!/usr/bin/env pythoon3
2
- """Read AVS dats file."""
3
- import sys
4
- import re
5
- from argparse import ArgumentParser
6
- from pathlib import Path
7
-
8
- import dateutil.parser
9
- import openpyxl as XL
10
- from openpyxl.cell.cell import MergedCell
11
- from openpyxl.utils.exceptions import InvalidFileException
12
-
13
- try:
14
- import itkdb_gtk
15
-
16
- except ImportError:
17
- cwd = Path(__file__).parent.parent
18
- sys.path.append(cwd.as_posix())
19
-
20
- from itkdb_gtk import ITkDBlogin, ITkDButils
21
-
22
- sk_defaults = {
23
- "institution": "AVS",
24
- "runNumber": "1",
25
- }
26
-
27
-
28
- class AVSDataException(Exception):
29
- """AVSData exception class."""
30
-
31
- def __init__(self, message):
32
- """Call the base class constructor with the parameters it needs."""
33
- super().__init__(message)
34
-
35
-
36
- def create_weight(session, SN, the_date=None, manager="", passed=True, problems=False, comments=None):
37
- """Creates the dictionary for a WEIGHT test.
38
-
39
- Args:
40
- session: the DB session
41
- SN: Serial Number
42
- the_date: the date of the test
43
- manager: manager name
44
- passed: if test passed or not
45
- problems: if problems were found during test
46
- comments: list of comments to append to the test
47
-
48
- """
49
- if comments is None:
50
- comments = []
51
-
52
- the_date = ITkDButils.get_db_date(the_date)
53
- out = ITkDButils.get_test_skeleton(session, "CORE_PETAL", "WEIGHING", sk_defaults)
54
- out['component'] = SN
55
- out['date'] = the_date
56
- out["institution"] = "AVS"
57
- out["runNumber"] = "1"
58
- out['passed'] = passed
59
- out['problems'] = problems
60
- out['properties']['PRODUCTION_MANAGER'] = manager
61
- out['comments'] = comments
62
- return out
63
-
64
-
65
- def create_manufacturing(session, SN, the_date=None, manager="", passed=True, problems=False, comments=None):
66
- """Create the dictionary or the MANUFACTURING test.
67
-
68
- Args:
69
- session: the DB session
70
- SN: Serial Number
71
- the_date: the date of the test
72
- manager: manager name
73
- passed: if test passed or not
74
- problems: if problems were found during test
75
- comments: list of comments to append to the test
76
-
77
- """
78
- if comments is None:
79
- comments = []
80
- the_date = ITkDButils.get_db_date(the_date)
81
- out = ITkDButils.get_test_skeleton(session, "CORE_PETAL", "MANUFACTURING", sk_defaults)
82
- out['component'] = SN
83
- out['date'] = the_date
84
- out["institution"] = "AVS"
85
- out["runNumber"] = "1"
86
- out['passed'] = passed
87
- out['problems'] = problems
88
- out['properties']['PRODUCTION_MANAGER'] = manager
89
- out['comments'] = comments
90
-
91
- return out
92
-
93
-
94
- def create_visual_inpection(session, SN, the_date=None, operator="", passed=True, problems=False, comments=None):
95
- """Create Visual Inspection test skeleton."""
96
- if comments is None:
97
- comments = []
98
- the_date = ITkDButils.get_db_date(the_date)
99
- out = ITkDButils.get_test_skeleton(session, "CORE_PETAL", "VISUAL_INSPECTION", sk_defaults)
100
- out['component'] = SN
101
- out["institution"] = "AVS"
102
- out["runNumber"] = "1"
103
- out['date'] = the_date
104
- out['passed'] = passed
105
- out['problems'] = problems
106
- out['properties']['OPERATOR'] = operator
107
- out['comments'] = comments
108
-
109
- return out
110
-
111
-
112
- def create_delamination_test(session, SN, the_date=None, operator="", passed=True, problems=False, comments=None):
113
- """Create the delamination test JSON.
114
-
115
- Args:
116
- session: the DB session
117
- SN: Serial Number
118
- the_date: the date of the test
119
- operator: operator name
120
- passed: if test passed or not
121
- problems: if problems were found during test
122
- comments: list of comments to append to the test
123
-
124
- """
125
- if comments is None:
126
- comments = []
127
-
128
- the_date = ITkDButils.get_db_date(the_date)
129
- out = ITkDButils.get_test_skeleton(session, "CORE_PETAL", "DELAMINATION", sk_defaults, {"boolean": False})
130
- out['component'] = SN
131
- out['date'] = the_date
132
- out["institution"] = "AVS"
133
- out["runNumber"] = "1"
134
- out['passed'] = passed
135
- out['problems'] = problems
136
- out['properties']['OPERATOR'] = operator
137
- out['comments'] = comments
138
-
139
- return out
140
-
141
-
142
- def create_grounding_test(session, SN, the_date=None, operator="", passed=True, problems=False, comments=None):
143
- """Create grounding test.
144
-
145
- Args:
146
- session: the DB session
147
- SN: Serial Number
148
- the_date: the date of the test
149
- operator: operator name
150
- passed: if test passed or not
151
- problems: if problems were found during test
152
- comments: list of comments to append to the test
153
-
154
- """
155
- if comments is None:
156
- comments = []
157
- the_date = ITkDButils.get_db_date(the_date)
158
- out = ITkDButils.get_test_skeleton(session, "CORE_PETAL", "GROUNDING_CHECK", sk_defaults, {"boolean": False})
159
- out['component'] = SN
160
- out['date'] = the_date
161
- out["institution"] = "AVS"
162
- out["runNumber"] = "1"
163
- out['passed'] = passed
164
- out['problems'] = problems
165
- out['properties']['OPERATOR'] = operator
166
- out['comments'] = comments
167
-
168
- return out
169
-
170
-
171
- def create_metrology_test(session, SN, the_date=None, operator="", passed=True, problems=False, comments=None):
172
- """Metrology test.
173
-
174
- Args:
175
- session: the DB session
176
- SN: Serial Number
177
- the_date: the date of the test
178
- operator: operator name
179
- passed: if test passed or not
180
- problems: if problems were found during test
181
- comments: list of comments to append to the test
182
-
183
- """
184
- if comments is None:
185
- comments = []
186
-
187
- the_date = ITkDButils.get_db_date(the_date)
188
- out = ITkDButils.get_test_skeleton(session, "CORE_PETAL", "METROLOGY_AVS",
189
- sk_defaults, {"integer": -1, "float": -1.0})
190
- out['component'] = SN
191
- out['date'] = the_date
192
- out['passed'] = passed
193
- out["institution"] = "AVS"
194
- out["runNumber"] = "1"
195
- out['problems'] = problems
196
- out['properties']['OPERATOR'] = operator
197
- out['comments'] = comments
198
-
199
- return out
200
-
201
-
202
- def split_comp_list(lst):
203
- """Split a list of components separated by various possible characters."""
204
- if lst is None:
205
- return []
206
-
207
- if isinstance(lst, float):
208
- return [lst]
209
-
210
- if isinstance(lst, int):
211
- return [lst]
212
-
213
- out = [lst]
214
- for sep in ['/', '\\', '\n']:
215
- if lst.find(sep) >= 0:
216
- out = [x.strip() for x in lst.split(sep)]
217
- break
218
-
219
- return out
220
-
221
-
222
- def get_comments(txt):
223
- """Return test DB comment."""
224
- return split_comp_list(txt)
225
-
226
-
227
- def get_float(cell, separator=None, default=0.0):
228
- """Return float from string."""
229
- txt = cell.value
230
- if txt is None:
231
- return default
232
-
233
- if separator is None:
234
- if isinstance(txt, float):
235
- return txt
236
-
237
- if isinstance(txt, int):
238
- return float(txt)
239
-
240
- if isinstance(txt, str):
241
- try:
242
- txt = txt.replace(',', '.')
243
- rr = re.findall(r"[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?", txt)
244
- if len(rr) == 0:
245
- return default
246
-
247
- val = float(rr[0])
248
- return val
249
- except ValueError:
250
- return default
251
-
252
- return default
253
-
254
- else:
255
- values = []
256
- for val in split_comp_list(txt):
257
- if isinstance(val, float) or isinstance(val, int):
258
- values.append(val)
259
- else:
260
- try:
261
- v = float(val.strip().replace(',', '.'))
262
- except ValueError:
263
- print("get_float: Cannot convert {} in {}".format(val, cell.coordinate))
264
- v = default
265
-
266
- values.append(v)
267
-
268
- return values
269
-
270
- def get_int(cell, default=None):
271
- """Get an int from a cell."""
272
- value = cell.value
273
- if value is None:
274
- return default
275
-
276
- return int(value)
277
-
278
- def get_boolean(cell):
279
- """Get a boolean from a cell."""
280
- value = cell.value
281
- if value is None:
282
- return False
283
-
284
- else:
285
- txt = value.strip().lower()
286
- return txt == "pass"
287
-
288
-
289
- def get_text(cell):
290
- """Get a string from a cell."""
291
- value = cell.value
292
- if value:
293
- value = value.strip()
294
-
295
- return value
296
-
297
-
298
- def get_res_and_accep(sheet, indx):
299
- """Return result and acceptancee."""
300
- sval = sheet["g{}".format(indx)].value
301
- if isinstance(sval, float) or isinstance(sval, int):
302
- val = sval
303
-
304
- else:
305
- sval = ' '.join(sval.strip().split()).split()
306
-
307
- scale = 1.0
308
- try:
309
- rr = re.findall(r"[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?", sval[0])
310
- if len(rr) == 0:
311
- val = 0.0
312
- else:
313
- val = float(rr[0])
314
- if len(sval)>1:
315
- U = sval[1].upper()[0]
316
- if U=='G':
317
- scale = 1000
318
-
319
- except ValueError:
320
- val = 0
321
-
322
- val = val * scale
323
- #val = get_float(sheet["g{}".format(indx)])
324
- pass_val = sheet["h{}".format(indx)]
325
- if pass_val.value is None:
326
- # Operator did not set the PASS/FAIL thing
327
- accept = True
328
- else:
329
- accept = get_boolean(pass_val)
330
-
331
- return val, accept
332
-
333
-
334
- def find_idx(lst, val):
335
- """Return index of occurence of val in lst."""
336
- R = re.compile(val, re.DOTALL|re.IGNORECASE)
337
- idx = [i for i, x in enumerate(lst) if (x and R.search(x))]
338
- return idx
339
-
340
-
341
- def cell_value(sheet, coord):
342
- """Return the cell value."""
343
- cell = sheet[coord]
344
- if not isinstance(cell, MergedCell):
345
- return cell.value
346
-
347
- # "Oh no, the cell is merged!"
348
- for cell_range in sheet.merged_cells.ranges:
349
- if coord in cell_range:
350
- return cell_range.start_cell.value
351
-
352
- return None
353
-
354
-
355
- def check_for_problems(sheet, the_test, row_range):
356
- """Finds FAIL massages in the Acceptance column."""
357
- nfail = 0
358
- for row in range(row_range[0], row_range[1]):
359
- txt = get_text(sheet["h{}".format(row)])
360
- if txt is None:
361
- continue
362
-
363
- txt = txt.lower()
364
- if txt[0] == 'f':
365
- nfail += 1
366
- hdr = get_text(sheet["d{}".format(row)])
367
- reason = cell_value(sheet, "i{}".format(row))
368
-
369
- if reason:
370
- if len(reason) < 20:
371
- msg = "{}: {}".format(hdr, reason)
372
- the_test["defects"].append({"name": msg})
373
- else:
374
- the_test["defects"].append({"name": hdr,
375
- "description": reason})
376
-
377
- if nfail:
378
- the_test["passed"] = False
379
-
380
-
381
- def get_coreID(bustapeID):
382
- """Build core SN from bus tape SN."""
383
- SN = "20USEBC" + bustapeID[-7:]
384
- return SN
385
-
386
-
387
- def readFATfile(session, file_path, SN=None):
388
- """Read data from FAT excel file.
389
-
390
- Args:
391
- session: the DB session
392
- file_path: File path
393
- SN: COre serial number
394
-
395
- """
396
- # Open spreadsheet
397
- try:
398
- wb = XL.load_workbook(file_path)
399
- except InvalidFileException as ee:
400
- print("Could not open input file: ", file_path)
401
- print(ee)
402
- return None
403
-
404
- # Assume active sheet is the good one, otherwise will have to find in wb.sheetnames
405
- sheet = wb.active
406
- if sheet.max_row < 50 or sheet.max_column < 9:
407
- raise AVSDataException("Wrong FAT file")
408
-
409
- # Check the SN of the petal core
410
- if SN is None or len(SN) == 0:
411
- coreID = split_comp_list(sheet['C6'].value)
412
- if len(coreID) == 0:
413
- raise AVSDataException("Cannot figure out core SN in FAT file.")
414
-
415
- for cID in coreID:
416
- cmp = ITkDButils.get_DB_component(session, cID)
417
- if cmp["type"]["code"] == "BT_PETAL_FRONT":
418
- SN = get_coreID(cID)
419
- break
420
-
421
- batch = sheet['E6'].value
422
- operator = sheet['G6'].value
423
-
424
- txt = list(map(str.strip, sheet['i4'].value.split(':')))[1]
425
- test_date = dateutil.parser.parse(txt)
426
-
427
- # Get the test index
428
- test_name = [str(sheet[x][1].value) for x in range(1, sheet.max_row)]
429
- tests = [str(sheet[x][3].value) for x in range(1, sheet.max_row)]
430
-
431
- # This is to avoid adding 1 for cell names...
432
- tests.insert(0, None)
433
- test_name.insert(0, None)
434
-
435
- #
436
- # Visual inspection
437
- vi_text = get_text(sheet['i9'])
438
- vi_result = get_text(sheet['g9'])
439
- vi_pass = sheet['h9'].value.strip().lower() == "pass"
440
- vi_defects = []
441
- if vi_pass:
442
- if vi_result and len(vi_result):
443
- if vi_text and len(vi_text):
444
- vi_text = vi_result + '\n' + vi_text
445
- else:
446
- vi_text = vi_result
447
-
448
- else:
449
- vi_defects.append({"name": "PETAL_VI_DEFECT", "description": vi_result})
450
-
451
- vi_test = create_visual_inpection(session, SN, test_date, operator, vi_pass,
452
- comments=get_comments(vi_text))
453
- for df in vi_defects:
454
- vi_test["defects"].append(df)
455
-
456
- #
457
- # Delamination test
458
- dl_text = get_text(sheet['i10'])
459
- dl_result = get_text(sheet['g10'])
460
- dl_pass = sheet['h10'].value.strip().lower() == "pass"
461
- dl_defects = []
462
- if dl_pass:
463
- if dl_result and len(dl_result):
464
- if dl_text and len(dl_text):
465
- dl_text = dl_result + '\n' + dl_text
466
- else:
467
- dl_text = dl_result
468
-
469
- else:
470
- dl_defects.append({"name": "PETAL_DL_DEFECT",
471
- "description": dl_result})
472
-
473
- delamination_test = create_delamination_test(session, SN, test_date, operator, dl_pass,
474
- comments=get_comments(dl_text))
475
- for df in dl_defects:
476
- delamination_test["defects"].append(df)
477
-
478
- #
479
- # Conductivity
480
- # TODO: read proper rows
481
- grounding_test = create_grounding_test(session, SN, test_date, operator)
482
- cond_val, cond_pass = get_res_and_accep(sheet, tests.index("COND"))
483
- if "INS_LOOP" in tests:
484
- loop_val, loop_pass = get_res_and_accep(sheet, tests.index("INS_LOOP"))
485
- else:
486
- loop_val, loop_pass = get_res_and_accep(sheet, tests.index("INS"))
487
-
488
- if "INS_LOOP_GND" in tests:
489
- loop_gnd_val, loop_gnd_pass = get_res_and_accep(sheet, tests.index("INS_LOOP_GND"))
490
- else:
491
- loop_gnd_val, loop_gnd_pass = get_res_and_accep(sheet, tests.index("INS_FACE"))
492
-
493
- passed = cond_pass and loop_pass and loop_gnd_pass
494
- grounding_test["passed"] = passed
495
- grounding_test["results"]["RESISTANCE_FB"] = cond_val
496
- grounding_test["results"]["RESISTANCE_PIPES"] = loop_val
497
- grounding_test["results"]["RESISTANCE_PIPE_GND"] = loop_gnd_val
498
- #check_for_problems(sheet, grounding_test, [tests.index('COND'), tests.index("WEIGH")])
499
-
500
- #
501
- # Weight
502
- petal_weight, weight_pass = get_res_and_accep(sheet, tests.index("WEIGH"))
503
-
504
- #
505
- # Metrology AVS
506
- metrology_test = create_metrology_test(session, SN, test_date, operator)
507
- metrology_test["results"]["LOCATOR1_DIAMETER"] = get_float(sheet['g{}'.format(tests.index("PL01_DIAM"))])
508
- metrology_test["results"]["LOCATOR2_DIAMETER"] = get_float(sheet['g{}'.format(tests.index("PL02_DIAM"))])
509
- metrology_test["results"]["LOCATOR3_DIAMETER"] = get_float(sheet['g{}'.format(tests.index("PL03_DIAM"))])
510
- metrology_test["results"]["LOCATOR2_X"] = get_float(sheet['g{}'.format(find_idx(tests, "PL02_X")[0])])
511
- metrology_test["results"]["LOCATOR2_Y"] = get_float(sheet['g{}'.format(find_idx(tests, "PL02_Y")[0])])
512
- metrology_test["results"]["LOCATOR3_X"] = get_float(sheet['g{}'.format(find_idx(tests, "PL03_X")[0])])
513
- metrology_test["results"]["LOCATOR3_Y"] = get_float(sheet['g{}'.format(find_idx(tests, "PL03_Y")[0])])
514
- metrology_test["results"]["FIDUCIAL1_DIAMETER"] = get_float(sheet["g{}".format(find_idx(tests, "FD01_DIAM")[0])])
515
- metrology_test["results"]["FIDUCIAL1_X"] = get_float(sheet["g{}".format(find_idx(tests, "FD01_X")[0])])
516
- metrology_test["results"]["FIDUCIAL1_Y"] = get_float(sheet["g{}".format(find_idx(tests, "FD01_Y")[0])])
517
- metrology_test["results"]["FIDUCIAL2_DIAMETER"] = get_float(sheet["g{}".format(find_idx(tests, "FD02_DIAM")[0])])
518
- metrology_test["results"]["FIDUCIAL2_X"] = get_float(sheet["g{}".format(find_idx(tests, "FD02_X")[0])])
519
- metrology_test["results"]["FIDUCIAL2_Y"] = get_float(sheet["g{}".format(find_idx(tests, "FD02_Y")[0])])
520
- metrology_test["results"]["ANGLE_VCHANNEL"] = get_float(sheet["g{}".format(find_idx(tests, "VANGL")[0])])
521
- metrology_test["results"]["ENVELOPE"] = get_float(sheet["g{}".format(find_idx(tests, "ENVEL")[0])])
522
- metrology_test["results"]["COPLANARITY_FRONT"] = get_float(sheet["g{}".format(find_idx(tests, "F.PL_PLAN")[0])])
523
- metrology_test["results"]["LOCAL_FLATNESS_FRONT"] = get_float(sheet["g{}".format(find_idx(tests, "F.FS_PLAN")[0])], '/')
524
- metrology_test["results"]["PARALLELISM_FRONT"] = get_float(sheet["g{}".format(find_idx(tests, "F.PARAL")[0])])
525
- metrology_test["results"]["COPLANARITY_BACK"] = get_float(sheet["g{}".format(find_idx(tests, "B.PL_PLAN")[0])])
526
- metrology_test["results"]["LOCAL_FLATNESS_BACK"] = get_float(sheet["g{}".format(find_idx(tests, "B.FS_PLAN")[0])], '/')
527
- metrology_test["results"]["PARALLELISM_BACK"] = get_float(sheet["g{}".format(find_idx(tests, "B.PARAL")[0])])
528
-
529
- # Get defects
530
- check_for_problems(sheet, metrology_test, [tests.index("WEIGH")+1, sheet.max_row])
531
-
532
- return vi_test, delamination_test, grounding_test, metrology_test, batch, petal_weight
533
-
534
-
535
- def find_label(sheet, label, column, max_row=20):
536
- """Find label in given column
537
-
538
- Args:
539
- sheet (): The spread sheet
540
- label (): The label to search for
541
- column (): The column to scan.
542
-
543
- Return:
544
- indx (int) - the index. <0 means not found.
545
- """
546
- indx = -1
547
- for i in range(1, 15):
548
- val = sheet["{}{}".format(column, i)].value
549
- if val is None:
550
- continue
551
-
552
- if val.find(label)>=0:
553
- indx = i
554
- break
555
-
556
- return indx
557
-
558
- def readProductionSheet(session, file_path, SN):
559
- """Read data fro AVS PS.
560
-
561
- Args:
562
- session: the DB session
563
- file_path: path of input file
564
- SN: The serial number
565
- write_json: if true, test json is writen to file.
566
-
567
- """
568
- try:
569
- wb = XL.load_workbook(file_path)
570
- except InvalidFileException as ee:
571
- print("Could not open input file: ", file_path)
572
- print(ee.message)
573
- return None
574
-
575
- # Assume active sheet is the good one, otherwise will have tofind in wb.sheetnames
576
- sheet = wb.active
577
- if sheet.max_row > 30 or sheet.max_column > 8:
578
- raise AVSDataException("Wrong PS file")
579
-
580
- # Find the start
581
- indx = find_label(sheet, "PETAL", "A")
582
- if indx < 0:
583
- # Try with second column
584
- indx = find_label(sheet, "PETAL", "B")
585
- if indx < 0:
586
- print("Wrong Production Sheet.")
587
- return None
588
- else:
589
- icol = ord('B')
590
- ccol = 'B'
591
- else:
592
- icol = ord('A')
593
- ccol = 'A'
594
-
595
- i_items = find_label(sheet, "DRAWING", ccol)
596
- if i_items < 0:
597
- print("Wrong Production Sheet.")
598
- return None
599
-
600
- i_items += 1
601
-
602
- # Get the SN of the fron facesheet and create the Petal SN
603
- ID = sheet["{}{}".format(chr(icol+2), i_items)].value.strip()
604
- SN = get_coreID(ID)
605
- nn = get_int(sheet["{}{}".format(chr(icol+1), indx)])
606
- petal_id = "PPC.{:03d}".format(nn)
607
- mould_id = sheet["{}{}".format(chr(icol+1), indx+3)].value
608
-
609
- # find the date (use the end date)
610
- start_date = sheet["{}{}".format(chr(icol+4), indx+2)].value
611
- end_date = sheet["{}{}".format(chr(icol+4), indx+3)].value
612
- test_date = start_date
613
-
614
- manager = sheet["{}{}".format(chr(icol+4), indx+1)].value
615
-
616
- # Manufacturing
617
- id_col = chr(icol+2)
618
- w_col = chr(icol+3)
619
- n_col = chr(icol+4)
620
- comments = get_comments(sheet['a25'].value)
621
- manufacturing = create_manufacturing(session, SN, test_date, manager, comments=comments)
622
- manufacturing['properties']['START_DATE'] = ITkDButils.get_db_date(start_date)
623
- manufacturing['properties']['FINISH_DATE'] = ITkDButils.get_db_date(end_date)
624
- manufacturing["properties"]["MOULD_ID"] = mould_id
625
- manufacturing["properties"]["PROCESS_DOCUMENT"] = sheet["{}{}".format(chr(icol+4), indx)].value
626
- manufacturing["results"]["LOCATOR_A"] = sheet["{}{}".format(id_col, i_items+2)].value
627
- manufacturing["results"]["LOCATOR_B"] = sheet["{}{}".format(id_col, i_items+3)].value
628
- manufacturing["results"]["LOCATOR_C"] = sheet["{}{}".format(id_col, i_items+4)].value
629
- manufacturing["results"]["HONEYCOMBSET"] = split_comp_list( sheet["{}{}".format(id_col, i_items+5)].value)
630
- manufacturing["results"]["EPOXY_ADHESIVE"] = split_comp_list(sheet["{}{}".format(id_col, i_items+8)].value)
631
- manufacturing["results"]["EPOXY_PUTTY"] = split_comp_list( sheet["{}{}".format(id_col, i_items+9)].value)
632
- manufacturing["results"]["EPOXY_CONDUCTIVE"] = split_comp_list( sheet["{}{}".format(id_col, i_items+10)].value)
633
-
634
- # Weighing
635
- weighing = create_weight(session, SN, test_date, manager)
636
- scol = "{}{}:{}{}".format(w_col, i_items, w_col, i_items+10)
637
- comp_weight = [get_float(x[0]) for x in sheet[scol]]
638
- petal_weight = sum([float(x) for x in comp_weight])
639
- weighing["results"]["WEIGHT_FACING_FRONT"] = comp_weight[0]
640
- weighing["results"]["WEIGHT_FACING_BACK"] = comp_weight[1]
641
- weighing["results"]["WEIGHT_LOCATOR_A"] = comp_weight[2]
642
- weighing["results"]["WEIGHT_LOCATOR_B"] = comp_weight[3]
643
- weighing["results"]["WEIGHT_LOCATOR_C"] = comp_weight[4]
644
- weighing["results"]["WEIGHT_COOLINGLOOPASSEMBLY"] = comp_weight[6]
645
- weighing["results"]["WEIGHT_HONEYCOMBSET"] = comp_weight[5]
646
- weighing["results"]["WEIGHT_EPOXYADHESIVE"] = comp_weight[8]
647
- weighing["results"]["WEIGHT_EPOXYPUTTY"] = comp_weight[9]
648
- weighing["results"]["WEIGHT_EPOXYCONDUCTIVE"] = comp_weight[10]
649
- weighing["results"]["WEIGHT_CORE"] = petal_weight
650
-
651
- # Comments
652
- for i in range(i_items, i_items+11):
653
- cell_id = sheet['{}{}'.format(ccol, i)].value
654
- comment = sheet['{}{}'.format(n_col, i)].value
655
- if comment is not None:
656
- comment = comment.strip()
657
- if len(comment):
658
- msg = "{}: {}".format(cell_id, comment)
659
- weighing["comments"].append(msg)
660
-
661
- DESY = {
662
- "FacingFront": sheet["{}{}".format(id_col, i_items)].value.strip(),
663
- "FacingBack": sheet["{}{}".format(id_col, i_items+1)].value.strip(),
664
- "CoolingLoop": sheet["{}{}".format(id_col, i_items+6)].value.strip(),
665
- "AllcompSet": sheet["{}{}".format(id_col, i_items+7)].value.strip(),
666
- "HoneyCombSet": manufacturing["results"]["HONEYCOMBSET"]
667
- }
668
-
669
- return manufacturing, weighing, DESY, petal_id
670
-
671
-
672
- if __name__ == "__main__":
673
- parser = ArgumentParser()
674
- parser.add_argument('files', nargs='*', help="Input files")
675
- parser.add_argument("--SN", dest="SN", type=str, default="SNnnn",
676
- help="Module serial number")
677
-
678
- options = parser.parse_args()
679
- if len(options.files) == 0:
680
- print("I need an input file")
681
- sys.exit()
682
-
683
- dlg = ITkDBlogin.ITkDBlogin()
684
- client = dlg.get_client()
685
- if client is None:
686
- print("Could not connect to DB with provided credentials.")
687
- dlg.die()
688
- sys.exit()
689
-
690
- fnam = Path(options.files[0]).expanduser().resolve()
691
- # readProductionSheet(fnam, options.SN)
692
- readFATfile(client, fnam, options.SN)
693
- dlg.die()