class exploreFocalPlane: def __init__(self, db='Prod', prodServer='Prod', appSuffix=''): self.SR_htype = "LCA-11021_RTM" self.CR_htype = "LCA-10692_CRTM" self.raft_types = [self.SR_htype, self.CR_htype] if prodServer == 'Prod': pS = True else: pS = False self.connect = Connection(operator='richard', db=db, exp='LSST-CAMERA', prodServer=pS, appSuffix=appSuffix) def focalPlaneContents(self, parentName="LCA-10134_Cryostat-0001", htype='LCA-10134_Cryostat', when=None, run=None): # when format: %Y-%m-%dT%H:%M:%S.%f eg: 2016-11-11T04:24:35.0 kwds = { 'experimentSN': parentName, 'htype': htype, 'noBatched': 'true' } if run is not None: run_info = self.connect.getRunSummary(run=run) kwds['timestamp'] = run_info['begin'] elif when is not None: kwds['timestamp'] = when response = self.connect.getHardwareHierarchy(**kwds) raft_list = [] for ind in response: raft = ind['child_experimentSN'] # ignore mechanical rafts if 'MTR' in raft or ind[ "child_hardwareTypeName"] not in self.raft_types: continue slot = ind['slotName'] # kludge for first cryo definition with slot names as BayXY, not RXY if 'Bay' in slot: slot = slot.replace("Bay", "R") if ind['parent_experimentSN'] == parentName: raft_list.append([raft, slot]) return raft_list
class exploreREB(): def __init__(self, db='Prod', prodServer='Prod', appSuffix=''): if prodServer == 'Prod': pS = True else: pS = False self.connect = Connection(operator='richard', db=db, exp='LSST-CAMERA', prodServer=pS, appSuffix=appSuffix) def REBContents(self, REBName=None): kwds = { 'experimentSN': REBName, 'htype': 'LCA-13574', 'noBatched': 'true' } response = self.connect.getHardwareHierarchy(**kwds) # LCA-11721 is the ASPIC. aspic_list = [] for row in response: kid = row['child_experimentSN'] if '11721' in kid: aspic_list.append((kid, row['slotName'])) return aspic_list def ASPIC_parent(self, ASPIC_name=None, htype='LCA-11721'): # now find ASPIC for a REB kwds = { 'experimentSN': ASPIC_name, 'htype': htype, 'noBatched': 'true' } response = self.connect.getContainingHardware(**kwds) for child in response: if '13574' in child['parent_experimentSN']: parentREB = child['parent_experimentSN'] break return parentREB
class exploreRun(): def __init__(self, db='Prod', prodServer='Prod', appSuffix=''): if prodServer == 'Prod': pS = True else: pS = False self.connect = Connection(operator='richard', db=db, exp='LSST-CAMERA', prodServer=pS, appSuffix=appSuffix) def hardware_sn(self, run): run_info = self.connect.getRunSummary(run=run) return run_info['experimentSN'] def slot_raft_map(self, run, parentName="LCA-10134_Cryostat-0001"): run_info = self.connect.getRunSummary(run=run) kwds = { 'experimentSN': run_info['experimentSN'], 'htype': 'LCA-10134_Cryostat', 'noBatched': 'true', 'timestamp': run_info['begin'] } response = self.connect.getHardwareHierarchy(**kwds) raft_list = [] for ind in response: raft = ind['child_experimentSN'] # ignore mechanical rafts if 'MTR' in raft or ind[ "child_hardwareTypeName"] != "LCA-11021_RTM": continue slot = ind['slotName'] # kludge for first cryo definition with slot names as BayXY, not RXY if 'Bay' in slot: slot = slot.replace("Bay", "R") if ind['parent_experimentSN'] == parentName: raft_list.append([raft, slot]) return response
def get_raft_slot_info(): """ Return a dict, keyed by raft slot (e.g., 'R01') of tuples containing raft LSST ID (e.g., 'LCA-11021_RTM-017') and the "good" TS8 run number from https://confluence.slac.stanford.edu/display/LSSTCAM/List+of+Good+Runs """ cryostat_id = 'LCA-10134_Cryostat-0001' cryo_htype = 'LCA-10134_Cryostat' conn = Connection('jchiang', 'Prod', prodServer=True) resp = conn.getHardwareHierarchy(experimentSN=cryostat_id, htype=cryo_htype) raft_htype = 'LCA-11021_RTM' raft_slot_info = dict() for item in resp: if item['child_hardwareTypeName'] == raft_htype: raft_slot = f'R{item["slotName"][-2:]}' lsst_id = item['child_experimentSN'] raft_slot_info[raft_slot] \ = RaftInfo(lsst_id, ts8_good_runs[lsst_id]) return raft_slot_info
class CopyAssembly: def __init__(self, args): ''' Verify and store information passed in command-line argumens ''' self.lsst_id = None self.site = None self.loc = None self.conn = None self.args = args # Must of one of lsstId, number arguments if args.lsst_id is not None: self.lsst_id = args.lsst_id elif args.cmpnt_num is not None: self.lsst_id = ''.join([args.htype, '-', args.cmpnt_num]) else: raise NameError('Neither lsstId nor number supplied') # if --location option was used, check it has proper syntax if (args.siteloc) is not None: try: self.site, self.loc = (args.siteloc).split(':') except: print('--location argument of improper form') raise def formList(self, response, good_types): ''' response is the response from the getHierarchy query good_types are the hardware types of interest Returns a list of dicts, each containing information to be used in registering one component ''' outlist = [] didRoot = False print('Good types are ') for g in good_types: print(g) for r in response: chtype = r['child_hardwareTypeName'] if chtype not in good_types: print(chtype, ' not in list of hardware types') continue if r['level'] == '0': if not didRoot: dict0 = {} dict0['level'] = 0 dict0['found'] = False phtype = r['parent_hardwareTypeName'] pexpSN = r['parent_experimentSN'] dict0['htype'] = phtype dict0['leaf'] = False try: rootInfos = self.conn.getHardwareInstances( htype=phtype, experimentSN=pexpSN) rootInfo = rootInfos[0] for k in rootInfo: dict0[k] = rootInfo[k] outlist.append(dict0) didRoot = True print("Appended to outlist") except: raise print('processing type ', chtype) cdict = {} cdict['parent'] = r['parent_experimentSN'] cdict['slotName'] = r['slotName'] cdict['relationshipName'] = r['relationshipTypeName'] cdict['level'] = int(r['level']) + 1 cdict['htype'] = chtype cdict['leaf'] = True # default assumption cexpSN = r['child_experimentSN'] try: infos = self.conn.getHardwareInstances(htype=chtype, experimentSN=cexpSN) info = infos[0] for k in info: cdict[k] = info[k] outlist.append(cdict) print("Appended to outlist") except: raise print('len of out list is ', len(outlist)) for cdict in outlist: for r in response: if r['parent_experimentSN'] == cdict['experimentSN'] and r[ 'parent_hardwareTypeName'] == cdict['htype']: cdict['leaf'] = False return outlist def register(self, elt): if self.site is None: site, location = elt['location'].split(':') else: site = self.site location = self.loc newId = self.conn.registerHardware( htype=elt['htype'], site=site, location=location, experimentSN=elt['experimentSN'], manufacturerId=elt['manufacturerId'], manufacturer=elt['manufacturer'], model=elt['model']) def setReady(self, elt, forReal): if forReal: self.conn.setHardwareStatus(experimentSN=elt['experimentSN'], htype=elt['htype'], status='READY', reason='Set by copy_assembly') print('Set status to READY for component ', elt['experimentSN']) else: print('Would have set status to READY for component ', elt['experimentSN']) def execute(self): source_list = [] args = self.args uname = args.u if uname is None: uname = os.getenv('USER') source_db = self.args.source_db print('Connecting to database ', source_db) self.conn = Connection(uname, source_db, prodServer=True, debug=False) rsp = [] try: print("Results from getHardwareHierarchy unfiltered:") iDict = 0 rsp = self.conn.getHardwareHierarchy(experimentSN=self.lsst_id, htype=args.htype, noBatched='true') source_list = self.formList(rsp, args.child_types) print('#Components found is ', len(source_list)) for elt in source_list: print('An element: ', elt['experimentSN'], elt['manufacturerId']) if elt['level'] > 0: print(' ', elt['parent'], elt['slotName']) except Exception as msg: print('Query of source db failed with exception: ') print(msg) sys.exit(1) ### Stuff to be properly indented # Make new connection to dest db print('Connecting to database ', args.dest_db) forReal = args.forreal if args.forreal: print('Continue for real? Y or N?') try: ans = raw_input('--> ') except NameError: ans = input('--> ') if ans[0] != 'Y': print('Switching to dry-run behavior') forReal = False self.conn = Connection(uname, args.dest_db, prodServer=True, debug=False) # SHOULD check that hardware types exist, but for now just hope for the best # Query will fail # we get the wrong answer.) # Query dest db to find out which ones exist; create any that don't # For now do this one by one. Could instead make 1 query per htype for elt in source_list: print('Working on component ', elt['experimentSN']) #print('Value for key leaf is: ', elt['leaf']) try: rs = self.conn.getHardwareInstances( htype=elt['htype'], experimentSN=elt['experimentSN']) print('Component found in dest db. No register action') except ETClientAPINoDataException: print('Did not find corresponding component in dest db') if (forReal): self.register(elt) else: print('Dryrun. No attempt to create entry') pass except: raise if elt['leaf'] is True: self.setReady(elt, forReal)
print ('For key %s returned value is %s\n' % (k, rsp[k]) ) # sys.exit(0) except Exception,msg: print 'Operation failed with exception: ' print msg sys.exit(1) rsp = [] try: # rsp = conn.getHardwareHierarchy(experimentSN='LCA-10753_RSA-002_CTE_ETU', # htype='LCA-10753_RSA', # noBatched='false') rsp = conn.getHardwareHierarchy(experimentSN=siteUtils.getUnitId(), htype=siteUtils.getUnitType(), noBatched='false') print "Results from getHardwareHierarchy unfiltered:" iDict = 0 for d in rsp: print('Examining array element %d' % (iDict)) isaccd = False ccd_sn = "" ccd_slot = "" ccd_htype = "" got_manu_info = False for k in d: if "ccd" in k.lower() : print('For key {0} value is {1}'.format(k, d[k])) if ('child_hardwareTypeName value' in k and ('itl-ccd' in d[k].lower() or 'e2v-ccd' in d[k].lower()) ) : isaccd = True
class exploreRaft(): def __init__(self, db='Prod', prodServer='Dev', appSuffix='-jrb'): if prodServer == 'Prod': pS = True else: pS = False self.connect = Connection(operator='richard', db=db, exp='LSST-CAMERA', prodServer=pS, appSuffix=appSuffix) def raftContents(self, raftName=None): kwds = { 'experimentSN': raftName, 'htype': 'LCA-11021_RTM', 'noBatched': 'true' } response = self.connect.getHardwareHierarchy(**kwds) # LCA-13574 is the REB. reb_list = [] for row in response: kid = row['child_experimentSN'] if '13574' in kid: reb_list.append((kid, row['slotName'])) # match up the CCD to the REB via REB and slot numbering. The CCD in slot # Sxy is on REBx. Note that the CCD is actually # assembled onto the RSA. ccd_list = [] for child in response: # print child['parent_experimentSN'], child['relationshipTypeName'], # child['child_experimentSN'], child['slotName'] kid = child['child_experimentSN'] if 'ITL' in kid.upper() or 'E2V' in kid.upper(): slotName = child['slotName'] rebNumber = slotName[1] for reb in reb_list: rebLoc = reb[1][3] if rebLoc == rebNumber: rebId = reb[0] break ccd_list.append((kid, slotName, rebId)) return ccd_list def CCD_parent(self, CCD_name=None, htype='ITL-CCD'): # now find raft for a CCD kwds = {'experimentSN': CCD_name, 'htype': htype, 'noBatched': 'true'} # connect = connection.Connection('richard', db='Dev', exp='LSST-CAMERA', prodServer=True) response = self.connect.getContainingHardware(**kwds) for child in response: if 'RTM' in child['parent_experimentSN']: parentRTM = child['parent_experimentSN'] break return parentRTM def REB_parent(self, REB_name=None): # now find raft for a REB kwds = { 'experimentSN': REB_name, 'htype': 'LCA-13574', 'noBatched': 'true' } # need to fix REB htype! response = self.connect.getContainingHardware(**kwds) for child in response: if 'RTM' in child['parent_experimentSN']: parentRTM = child['parent_experimentSN'] break return parentRTM def REB_CCD(self, REB_name=None): raft = self.REB_parent(REB_name) ccd_list = self.raftContents(raft) ccd_in_reb = [] for ccd in ccd_list: if REB_name == ccd[2]: ccd_in_reb.append(ccd[0]) return ccd_in_reb
class exploreRaft(): def __init__(self, db='Prod', prodServer='Prod', appSuffix=''): self.SR_htype = "LCA-11021_RTM" self.CR_htype = "LCA-10692_CRTM" self.REB_htype = "LCA-13574" self.WREB_htype = "LCA-13537" self.GREB_htype = "LCA-13540" if prodServer == 'Prod': pS = True else: pS = False self.connect = Connection(operator='richard', db=db, exp='LSST-CAMERA', prodServer=pS, appSuffix=appSuffix) def raftContents(self, raftName=None, when=None, run=None): # when format: %Y-%m-%dT%H:%M:%S.%f eg: 2016-11-11T04:24:35.0 raft_htype = self.SR_htype if self.CR_htype in raftName: raft_htype = self.CR_htype kwds = { 'experimentSN': raftName, 'htype': raft_htype, 'noBatched': 'true' } if run is not None: run_info = self.connect.getRunSummary(run=run) kwds['timestamp'] = run_info['begin'] elif when is not None: kwds['timestamp'] = when response = self.connect.getHardwareHierarchy(**kwds) # LCA-13574 is the REB. reb_list = [] for row in response: kid = row['child_experimentSN'] if self.REB_htype in kid or self.WREB_htype in kid or self.GREB_htype in kid: reb_list.append((kid, row['slotName'])) # match up the CCD to the REB via REB and slot numbering. The CCD in slot # Sxy is on REBx. Note that the CCD is actually # assembled onto the RSA. ccd_list = [] for child in response: # print child['parent_experimentSN'], child['relationshipTypeName'], # child['child_experimentSN'], child['slotName'] rebId = "" kid = child['child_experimentSN'] if 'ITL' in kid.upper() or 'E2V' in kid.upper(): slotName = child['slotName'] if raft_htype == self.SR_htype: slotNumber = 3 else: slotNumber = 0 for reb in reb_list: rebLoc = reb[1][slotNumber] # two CCDs per GREB, but treated as 1 if self.GREB_htype in reb[0] and "3800C" in kid: rebId = reb[0] slotName = "guider" break # 2 CCDs per WREB elif self.WREB_htype in reb[0] and "4400B" in kid: rebId = reb[0] break elif self.REB_htype in reb[0]: # CCD slotname first digit encodes the REB number rebNumber = slotName[1] if rebLoc == rebNumber: rebId = reb[0] break else: continue ccd_list.append((kid, slotName, rebId)) return ccd_list def raft_type(self, raft=None): ccd_list = self.raftContents(raftName=raft) if 'ITL' in ccd_list[0][0]: type = 'ITL' else: type = 'e2v' return type def CCD_parent(self, CCD_name=None, htype='ITL-CCD', when=None, run=None): # now find raft for a CCD kwds = {'experimentSN': CCD_name, 'htype': htype, 'noBatched': 'true'} if run is not None: run_info = self.connect.getRunSummary(run=run) kwds['timestamp'] = run_info['begin'] elif when is not None: kwds['timestamp'] = when # connect = connection.Connection('richard', db='Dev', exp='LSST-CAMERA', prodServer=True) response = self.connect.getContainingHardware(**kwds) parentRTM = "" for child in response: if 'RTM' in child['parent_experimentSN']: parentRTM = child['parent_experimentSN'] break return parentRTM def REB_parent(self, REB_name=None, when=None, run=None): # now find raft for a REB htype = REB_name.rsplit("-", 1)[0] kwds = { 'experimentSN': REB_name, 'htype': htype, 'noBatched': 'true' } # need to fix REB htype! if run is not None: run_info = self.connect.getRunSummary(run=run) kwds['timestamp'] = run_info['begin'] elif when is not None: kwds['timestamp'] = when response = self.connect.getContainingHardware(**kwds) parentRTM = "" for child in response: if 'RTM' in child['parent_experimentSN']: parentRTM = child['parent_experimentSN'] break return parentRTM def REB_CCD(self, REB_name=None, when=None, run=None): raft = self.REB_parent(REB_name) if run is not None: run_info = self.connect.getRunSummary(run=run) when = run_info['begin'] ccd_list = self.raftContents(raftName=raft, when=when) ccd_in_reb = [] for ccd in ccd_list: if REB_name == ccd[2]: ccd_in_reb.append(ccd[0]) return ccd_in_reb
for k in rsp: print('For key %s returned value is %s\n' % (k, rsp[k])) # sys.exit(0) except Exception, msg: print 'Operation failed with exception: ' print msg sys.exit(1) rsp = [] try: # rsp = conn.getHardwareHierarchy(experimentSN='LCA-10753_RSA-002_CTE_ETU', # htype='LCA-10753_RSA', # noBatched='false') rsp = conn.getHardwareHierarchy(experimentSN=siteUtils.getUnitId(), htype=siteUtils.getUnitType(), noBatched='false') print "Results from getHardwareHierarchy unfiltered:" iDict = 0 for d in rsp: print('Examining array element %d' % (iDict)) isaccd = False ccd_sn = "" ccd_slot = "" ccd_htype = "" got_manu_info = False for k in d: if "ccd" in k.lower(): print('For key {0} value is {1}'.format(k, d[k])) if ('child_hardwareTypeName value' in k and ('itl-ccd' in d[k].lower() or 'e2v-ccd' in d[k].lower())):
def PrepareInfo(): ### Prepare necesarry information from eTraveler p = re.compile(r".*CCD") connection = Connection(operator="youtsumi", db='Prod', exp='LSST-CAMERA', prodServer=True, localServer=False, appSuffix='', cnfPath='~/.ssh/.etapi.cnf') experimentSN = "LCA-10134_Cryostat-0001" htype = "LCA-10134_Cryostat" results = connection.getHardwareHierarchy(experimentSN=experimentSN, htype=htype) rebs = [] ccds = [] for Baylevel in results: if Baylevel['child_hardwareTypeName'] not in ('LCA-11021_RTM', 'LCA-10692_CRTM'): continue Bayinfo = connection.getHardwareInstances( htype=Baylevel['child_hardwareTypeName'], experimentSN=Baylevel['child_experimentSN'])[0] if Baylevel['child_hardwareTypeName'] == 'LCA-11021_RTM': flavor = (Bayinfo["model"].split("-")[2]) else: flavor = "ITL" print("#############") print(Bayinfo, Baylevel, flavor) print("#############") sub = connection.getHardwareHierarchy( experimentSN=Baylevel["child_experimentSN"], htype=Baylevel["child_hardwareTypeName"]) for areb in sub: # REB if areb['child_hardwareTypeName'] == 'LCA-13574': rebinfo = connection.getHardwareInstances( htype=areb['child_hardwareTypeName'], experimentSN=areb['child_experimentSN'])[0] rebs.append({ "Bay": Baylevel["slotName"], "Flavor": flavor, "Name": Baylevel['child_experimentSN'], "Slot": areb["slotName"].lower().capitalize(), "slot": areb["slotName"].lower().capitalize(), "SerialNum": rebinfo["manufacturerId"], "RebName": rebinfo["experimentSN"], "path": "R{:02d}".format( int(Baylevel["slotName"].replace("Bay", ""))) }) # RSA if areb['parent_hardwareTypeName'] == 'LCA-10753_RSA' and (p.match( areb["child_hardwareTypeName"]) is not None): sensorinfo = connection.getHardwareInstances( htype=areb['child_hardwareTypeName'], experimentSN=areb['child_experimentSN'])[0] ccds.append({ "Bay": Baylevel["slotName"], "Flavor": flavor, "Name": areb["child_experimentSN"], "Slot": areb["slotName"], "manSerNum": sensorinfo["manufacturerId"], "path": "R{:02d}/Reb{:01d}/{}".format( int(Baylevel["slotName"].replace("Bay", "")), int(areb["slotName"][1]), areb["slotName"]) }) # WGREB if areb['child_hardwareTypeName'] in [ 'LCA-13537', # WREB 'LCA-13540' # GREB ]: rebinfo = connection.getHardwareInstances( htype=areb['child_hardwareTypeName'], experimentSN=areb['child_experimentSN'])[0] rebs.append({ "Bay": Baylevel["slotName"], "Flavor": flavor, "Name": Baylevel['child_experimentSN'], "Slot": "WREB" if areb['child_hardwareTypeName'] == 'LCA-13537' else "GREB", "slot": "RebW" if areb['child_hardwareTypeName'] == 'LCA-13537' else "RebG", "RebName": rebinfo["experimentSN"], "SerialNum": rebinfo["manufacturerId"], "path": "R{:02d}".format( int(Baylevel["slotName"].replace("Bay", ""))) }) # CRSA print(areb) if ( areb['child_hardwareTypeName'] == "ITL-CCD" and areb["parent_hardwareTypeName"] == "LCA-10628" ) or \ ( areb['child_hardwareTypeName'] == "ITL-Wavefront-CCD" and areb["parent_hardwareTypeName"] == "LCA-10626" ): ccdhier = connection.getContainingHardware( htype=areb['child_hardwareTypeName'], experimentSN=areb['child_experimentSN']) if areb["parent_hardwareTypeName"] == "LCA-10628": # G slot = (ccdhier[1]["slotName"]) else: # W slot = "W{}".format((ccdhier[0]["slotName"])[-1]) sensorinfo = connection.getHardwareInstances( htype=areb['child_hardwareTypeName'], experimentSN=areb['child_experimentSN'])[0] ccds.append({ "Bay": Baylevel["slotName"], "Flavor": flavor, "Name": areb["child_experimentSN"], "Slot": areb["slotName"], "manSerNum": sensorinfo["manufacturerId"], "path": "R{:02d}/Reb{}/S{}{}".format( int(Baylevel["slotName"].replace("Bay", "")), slot[0].upper(), slot[0].upper(), int(slot[-1]) - 1) }) return rebs, ccds
def getCCDNames(): topdir = os.getcwd() topparts = topdir.split('/') activity_id = topparts[len(topparts) - 1] if not topdir: raise RuntimeError, 'cannot determine top-level data directory' limsurl = "" try: limsurl = os.environ['LCATR_LIMS_URL'] except: pass if ('/Prod' in limsurl): print "Connecting to eTraveler Prod" conn = Connection('homer', 'Prod', prodServer=True) else: print "Connecting to eTraveler Dev" conn = Connection('homer', 'Dev', prodServer=True) if not conn: raise RuntimeError, 'unable to authenticate' ccdnames = {} ccdmanunames = {} rsp = [] try: rsp = conn.getHardwareHierarchy(experimentSN=getUnitId(), htype=getUnitType(), noBatched='false') print "Results from getHardwareHierarchy unfiltered:" iDict = 0 for d in rsp: # print('Examining array element %d' % (iDict)) isaccd = False ccd_sn = "" ccd_slot = "" ccd_htype = "" ccd_manu_sn = "" got_ccd_manu = False for k in d: # print('For key {0} value is {1}'.format(k, d[k])) if ('child_hardwareTypeName' in str(k) and ('itl-ccd' in str(d[k].lower()) or 'e2v-ccd' in str(d[k].lower()))): isaccd = True print "found CCD specs" if (isaccd and 'child_experimentSN' in str(k)): ccd_sn = str(d[k]) print "CCD SN = %s" % ccd_sn if (isaccd and 'slotName' in str(k)): ccd_slot = str(d[k]) print "slot = %s" % ccd_slot if (isaccd and 'child_hardwareTypeName' in str(k)): ccd_htype = str(d[k]) if (isaccd and ccd_sn != "" and ccd_htype != "" and not got_ccd_manu): print "trying to get Manufacturer ID for ccd_sn=%s , ccd_htype=%s" % ( ccd_sn, ccd_htype) try: ccd_manu_sn = conn.getManufacturerId( experimentSN=ccd_sn, htype=ccd_htype) print 'Manufacturer ID: ', ccd_manu_sn got_ccd_manu = True except ValueError, msg: print 'Operation failed with ValueError: ', msg except Exception, msg: print 'Operation failed with exception: ' print msg sys.exit(1)
def getCCDNames(): topdir = os.getcwd() topparts = topdir.split('/') activity_id = topparts[len(topparts) - 1] if not topdir: raise RuntimeError('cannot determine top-level data directory') limsurl = os.getenv('LCATR_LIMS_URL', default='') if '/Prod' in limsurl: print("Connecting to eTraveler Prod") conn = Connection('homer', 'Prod', prodServer=False) else: print("Connecting to eTraveler Dev") conn = Connection('homer', 'Dev', prodServer=False) if not conn: raise RuntimeError('unable to authenticate') ccdnames = {} ccdmanunames = {} rsp = [] try: rsp = conn.getHardwareHierarchy(experimentSN=getUnitId(), htype=getUnitType(), noBatched='false') print("Results from getHardwareHierarchy unfiltered:") iDict = 0 for d in rsp: # print('Examining array element %d' % (iDict)) isaccd = False ccd_sn = "" ccd_slot = "" ccd_htype = "" ccd_manu_sn = "" got_ccd_manu = False for k in d: # print('For key {0} value is {1}'.format(k, d[k])) if ('child_hardwareTypeName' in str(k) and ('itl-ccd' in str(d[k].lower()) or 'e2v-ccd' in str(d[k].lower()))): isaccd = True print("found CCD specs") if isaccd and 'child_experimentSN' in str(k): ccd_sn = str(d[k]) print("CCD SN = %s" % ccd_sn) if isaccd and 'slotName' in str(k): ccd_slot = str(d[k]) print("slot = %s" % ccd_slot) if isaccd and 'child_hardwareTypeName' in str(k): ccd_htype = str(d[k]) if (isaccd and ccd_sn != "" and ccd_htype != "" and not got_ccd_manu): print( "trying to get Manufacturer ID for ccd_sn=%s , ccd_htype=%s" % (ccd_sn, ccd_htype)) try: ccd_manu_sn = conn.getManufacturerId( experimentSN=ccd_sn, htype=ccd_htype) print('Manufacturer ID: ', ccd_manu_sn) got_ccd_manu = True except ValueError as eobj: print('Operation failed with ValueError:', eobj) except Exception as eobj: print('Operation failed with exception:', eobj) sys.exit(1) iDict += 1 if isaccd: ccdnames[ccd_slot] = ccd_sn ccdmanunames[ccd_slot] = ccd_manu_sn except Exception as eobj: print('Operation failed with exception: ') print(str(eobj)) sys.exit(1) print("Returning the following list of CCD names and locations") print("ccdnames") return ccdnames, ccdmanunames