def handle(self, *args, **options): settings = Settings() active_run = settings.get_active_run() for wildCard in args : fileNames = glob.glob(wildCard) for inFileName in fileNames : inFile = open(inFileName) for line in inFile : e = ET.XML(line) sts = e.getiterator('timestamp')[0].text witsdatas = e.getiterator('witsdata') for data in witsdatas : id = data.getiterator('identifier')[0].text value = data.getiterator('value')[0].text wits0 = WITS0(run=active_run, time_stamp=sts, recid=id[:2], itemid=id[2:], value=value ) wits0.save()
def handle(self, *args, **options): settings = Settings() active_well = settings.get_active_well() d = 100 h = d for cnt in range(100): m = 1 if int(random.uniform(1, 10)) == 1: m = -1 d += int(random.uniform(1, 10)) * m if d - ((d / 100) * 100) <= 20 and d > 120: g = int(random.uniform(90, 110)) else: g = int(random.uniform(30, 35)) if d > h: h = d bd = WITS0(well=active_well, time_stamp=datetime.utcnow(), recid=1, itemid=8, value=d) bd.save() hd = WITS0(well=active_well, time_stamp=datetime.utcnow(), recid=1, itemid=10, value=h) hd.save() time.sleep(10) mdwrt = ToolMWDRealTime(well=active_well, time_stamp=datetime.utcnow(), type="gammaray", value=g) mdwrt.save() time.sleep(10)
def handle(self, *args, **options): settings = Settings() active_well = settings.get_active_well() g = 30 m = 1 for cnt in range(100) : g += (int(random.uniform(1,15)) * m) print g mdwrt = ToolMWDRealTime(well=active_well, time_stamp=datetime.utcnow(), type='gammaray', value=g ) mdwrt.save() if g>75 : m=-1 if g<30 : m=1 time.sleep(20)
def handle(self, *args, **options): settings = Settings() active_run = settings.get_active_run() for wildCard in args : fileNames = glob.glob(wildCard) for inFileName in fileNames : inFile = open(inFileName) for line in inFile : e = ET.XML(line) type = e.getiterator('type')[0].text value = e.getiterator('value')[0].text sts = e.getiterator('timestamp')[0].text try : timestamp = datetime.strptime(sts[:8]+sts[12:],'%I:%M:%S %p %m/%d/%Y') microsecond = int(sts[9:12]) * 1000 timestamp.replace(microsecond=microsecond) except ValueError: try : timestamp = datetime.strptime(sts, '%I:%M:%S.%p %m/%d/%Y') except ValueError: timestamp = datetime.strptime(sts[:7]+sts[11:],'%I:%M:%S %p %m/%d/%Y') microsecond = int(sts[8:11]) * 1000 timestamp.replace(microsecond=microsecond) if type not in self.value_types.keys() : print 'unknown type:', type continue mdwrt = MWDRealTime(run=active_run, time_stamp=timestamp, type=self.value_types[type], value=int(float(value)) ) mdwrt.save()