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 if (isaccd and 'child_experimentSN' in str(k)) : ccd_sn = str(d[k]) if (isaccd and 'slotName' in str(k)) : ccd_slot = str(d[k]) if (isaccd and 'child_hardwareTypeName' in str(k)) : ccd_htype = str(d[k]) if (isaccd and ccd_sn != "" and ccd_htype != "" and not got_manu_info) : print "trying to get Manufacturer ID for ccd_sn=%s , ccd_htype=%s" % (ccd_sn,ccd_htype) try: rsp = conn.getManufacturerId(experimentSN=ccd_sn, htype=ccd_htype) print 'Manufacturer ID: ', rsp got_manu_info = True except ValueError,msg: print 'Operation failed with ValueError: ', msg except Exception,msg: print 'Operation failed with exception: ' print msg sys.exit(1) iDict +=1 # sys.exit(0) 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 = "" 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)
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 if (isaccd and 'child_experimentSN' in str(k)): ccd_sn = str(d[k]) if (isaccd and 'slotName' in str(k)): ccd_slot = str(d[k]) if (isaccd and 'child_hardwareTypeName' in str(k)): ccd_htype = str(d[k]) if (isaccd and ccd_sn != "" and ccd_htype != "" and not got_manu_info): print "trying to get Manufacturer ID for ccd_sn=%s , ccd_htype=%s" % ( ccd_sn, ccd_htype) try: rsp = conn.getManufacturerId(experimentSN=ccd_sn, htype=ccd_htype) print 'Manufacturer ID: ', rsp got_manu_info = True except ValueError, msg: print 'Operation failed with ValueError: ', msg except Exception, msg: print 'Operation failed with exception: ' print msg sys.exit(1) iDict += 1 # sys.exit(0) 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