easy-utils-dev 2.130__py3-none-any.whl → 2.132__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.
easy_utils_dev/ept.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import xml.etree.ElementTree as ET
2
2
  from bs4 import BeautifulSoup
3
3
  from easy_utils_dev.simple_sqlite import initDB
4
- from easy_utils_dev.utils import getRandomKey , getTimestamp , lget , mkdirs
4
+ from easy_utils_dev.utils import getRandomKey , getTimestamp , lget , mkdirs , start_thread
5
5
  import json , os , glob
6
6
  from easy_utils_dev.FastQueue import FastQueue
7
7
  from easy_utils_dev.debugger import DEBUGGER
@@ -174,7 +174,6 @@ class EPTManager :
174
174
  def _create_v_dirs(self) :
175
175
  db = self.Database()
176
176
  dirs = self.get_all_dirs()
177
-
178
177
  db.createTable(
179
178
  'c_dirs' ,
180
179
  data=[
@@ -256,7 +255,7 @@ class EPTManager :
256
255
 
257
256
  def _create_crossconnections_table(self) :
258
257
  query = f"""
259
- CREATE TABLE c_crossconnections AS
258
+ CREATE VIEW c_crossconnections AS
260
259
  SELECT DISTINCT
261
260
  p.owner as wdmdemand,
262
261
  sh.number || '-' || sm.physicalslot || '-L' || p.portnumber as physicalslot ,
@@ -283,9 +282,96 @@ class EPTManager :
283
282
  db = self.Database()
284
283
  db.execute_dict(query)
285
284
 
285
+ def _create_ports_inventory(self) :
286
+ query = f"""
287
+ CREATE VIEW c_port_inventory AS
288
+ select
289
+ p.pluggable as moduletype,
290
+ p.pluggableapn as partnumber,
291
+ p.portnumber,
292
+ p.connectortype,
293
+ cp.slotid,
294
+ cp.id as eptpackid ,
295
+ p.id as eptpid ,
296
+ sh.id as eptshid ,
297
+ s.id as eptsid ,
298
+ sh.number as shelfid,
299
+ sm.physicalslot,
300
+ s.name as sitename,
301
+ CASE
302
+ WHEN p.connectortype LIKE 'Line%'
303
+ THEN sh.number || '-' || sm.physicalslot || '-L' || p.portnumber
304
+ WHEN p.connectortype LIKE 'Client%'
305
+ THEN sh.number || '-' || sm.physicalslot || '-C' || p.portnumber
306
+ WHEN p.connectortype LIKE '%VOA%'
307
+ THEN sh.number || '-' || sm.physicalslot || '-VA' || p.portnumber
308
+ ELSE NULL
309
+ END as custom_portname ,
310
+ CASE
311
+ WHEN p.pluggable IS NULL AND physicalslot IS NOT NULL AND p.pluggableapn is NULL
312
+ THEN 'free'
313
+ ELSE 'busy'
314
+ END as portstatus
315
+ from port p
316
+ JOIN circuitpack cp ON p.parentId = cp.id
317
+ JOIN shelf sh ON cp.parentId = sh.id
318
+ JOIN site s ON sh.grandparentId = s.id
319
+ JOIN slot_mapping sm ON sh.type = sm.shelfType AND cp.slotid = sm.logicalSlot
320
+ JOIN OTtype ot ON ot.OTtype = cp.type
321
+ WHERE ( p.connectortype IS NOT NULL ) ;
322
+ """
323
+ db = self.Database()
324
+ db.execute_dict(query)
325
+
326
+ def _create_enhanced_dirs(self) :
327
+ query = f"""
328
+ CREATE VIEW c_enhanced_dirs AS
329
+ select DISTINCT
330
+ line.id as eptlineid ,
331
+ line.span as spanid ,
332
+ site.id as eptsitenameid ,
333
+ spn.name as eptsegementname ,
334
+ line.wdmlink as wdmlinkid ,
335
+ cp.type as boardtype ,
336
+ sh.type as shelftype,
337
+ sp.physicalslot as slot ,
338
+ sh.number as shelfid ,
339
+ site.name as sitename ,
340
+ segt.id as segementid ,
341
+
342
+ CASE
343
+ WHEN segt2.asite = site.id THEN site_b.name
344
+ WHEN segt2.bsite = site.id THEN site_a.name
345
+ END AS farsitename,
346
+
347
+ CASE
348
+ WHEN segtinfo.orient = 'AB' AND segt2.asite = site.id THEN segtinfo.dist
349
+ WHEN segtinfo.orient = 'AB' AND segt2.bsite = site.id THEN segtinfo.dist
350
+ WHEN segtinfo.orient = 'BA' AND segt2.asite = site.id THEN segtinfo.dist
351
+ WHEN segtinfo.orient = 'BA' AND segt2.bsite = site.id THEN segtinfo.dist
352
+ END AS distance ,
353
+ sh.number || "-" || sp.physicalSlot as fullslot
354
+ from line
355
+ JOIN circuitpack cp ON cp.wdmline = line.id AND ( cp.packIDRef IS NOT NULL OR cp.type = oa.OAtype )
356
+ JOIN site on site.id = sh.grandparentId
357
+ JOIN OAtype as oa
358
+ JOIN shelf sh ON sh.id = cp.parentId
359
+ JOIN slot_mapping sp on sp.logicalSlot = cp.slotid AND sh.type = sp.shelftype
360
+ JOIN span spn ON spn.id = line.span AND spn.ashelfset IS NOT NULL
361
+ JOIN segt ON segt.grandparentId = spn.id
362
+ JOIN segt segt2 ON segt.id = segt2.id AND segt2.asite IS NOT NULL
363
+ JOIN segtinfo ON segtinfo.parentId = segt.id
364
+ JOIN site AS site_a ON site_a.id = segt2.asite
365
+ JOIN site AS site_b ON site_b.id = segt2.bsite
366
+ GROUP BY line.id ;
367
+
368
+ """
369
+ db = self.Database()
370
+ db.execute_dict(query)
371
+
286
372
  def _create_card_inventory(self) :
287
373
  query = f"""
288
- CREATE TABLE c_card_inventory AS
374
+ CREATE VIEW c_card_inventory AS
289
375
  SELECT DISTINCT
290
376
  sh.number || '-' || pack.physicalslot AS slot,
291
377
  sh.number AS shelfid,
@@ -331,16 +417,55 @@ class EPTManager :
331
417
  db = self.Database()
332
418
  db.execute_dict(query)
333
419
 
420
+ def _create_shelf_inventory(self) :
421
+ query = f"""
422
+ CREATE VIEW c_shelf_info AS
423
+ SELECT
424
+ sh.type AS shelftype ,
425
+ sh.number AS shelfnumber,
426
+ sh.apn AS partnumber ,
427
+ st.name AS sitename
428
+ FROM shelf sh
429
+ JOIN site st ON st.id = sh.grandparentId
430
+ WHERE sh.number != 0
431
+ UNION ALL
432
+ SELECT
433
+ cp.type AS shelftype ,
434
+ cp.dcmpseudoshelf AS shelfnumber,
435
+ cp.apn AS partnumber ,
436
+ st.name as sitename
437
+ FROM circuitpack cp
438
+ JOIN shelf sh ON sh.id = cp.parentId
439
+ JOIN site st ON sh.grandparentId = st.id
440
+ WHERE cp.dcmpseudoshelf IS NOT NUll ;
441
+ """
442
+ db = self.Database()
443
+ db.execute_dict(query)
444
+
445
+ def _create_site_tmp_table(self) :
446
+ query = f"""
447
+ CREATE TABLE c_tmp_site_view AS
448
+ SELECT * FROM site;
449
+ """
450
+ db = self.Database()
451
+ db.execute_dict(query)
452
+
334
453
  def convert_design(self , drop_cols=[] ) :
335
454
  start = getTimestamp()
336
455
  db = self.Database()
337
456
  self.parse()
338
457
  self.create_ept_columns(drop_cols=drop_cols)
339
458
  self.create_ept_rows()
340
- db.execute_script(f"{os.path.join(__LIBPATH__ , 'ept_sql' , 'create_dirs.sql')}")
341
- self._create_v_dirs()
342
- self._create_crossconnections_table()
343
- self._create_card_inventory()
459
+ # db.execute_script(f"{os.path.join(__LIBPATH__ , 'ept_sql' , 'create_dirs.sql')}")
460
+ a = start_thread(self._create_v_dirs , daemon=True)
461
+ b = start_thread(self._create_crossconnections_table , daemon=True)
462
+ c = start_thread(self._create_card_inventory , daemon=True)
463
+ d = start_thread(self._create_shelf_inventory , daemon=True)
464
+ s = start_thread(self._create_site_tmp_table , daemon=True)
465
+ s = start_thread(self._create_ports_inventory , daemon=True)
466
+ s = start_thread(self._create_enhanced_dirs , daemon=True)
467
+ a.join() ; b.join() ; c.join() ; d.join() ; s.join()
468
+
344
469
  end = getTimestamp()
345
470
  if os.path.exists(self.tmp_design_path) :
346
471
  os.remove(self.tmp_design_path)
@@ -350,7 +475,7 @@ class EPTManager :
350
475
  db = self.Database()
351
476
  packs = self.get_all_amplifiers()
352
477
  _packs = []
353
- def __g_p(pack) :
478
+ for pack in packs :
354
479
  parentId = pack['parentId']
355
480
  wdmline = pack['wdmline']
356
481
  shelf = self.get_shelf_data_by_id(parentId)
@@ -385,9 +510,6 @@ class EPTManager :
385
510
  'SHELFTYPE' : shelfType ,
386
511
  })
387
512
  self.logger.debug(f"Source:{sourceNE}/{fullSlot}/{pack.get('type')} -> {spanId} -> {DestinationNE}")
388
- for pack in packs :
389
- self.queue.addToQueue(action=__g_p , actionArgs={'pack' : pack})
390
- self.queue.runQueue(maxRequests=10)
391
513
  return _packs
392
514
 
393
515