def run(self): start = get_millis() while self.isRunning.running: try: if self.stream is None: self.setup() start = get_millis() continue current = self.read_data() if len(current) == 0: time.sleep(SerialGrabber_Settings.reader_error_sleep) continue if self.startup_ignore_threshold_milliseconds > 0 and ( get_millis() - start) <= self.startup_ignore_threshold_milliseconds: self.logger.warn( "Dropping data received inside startup threshold.") continue if SerialGrabber_Settings.drop_carriage_return: current = current.replace("\r", "") self.transaction_extractor.write(current) except Exception, e: self.counter.error() import traceback traceback.print_exc() if self.stream is None: time.sleep(SerialGrabber_Settings.reader_error_sleep)
def run(self): start = get_millis() while self.isRunning.running: try: if self.stream is None: self.setup() start = get_millis() continue current = self.read_data() if len(current) == 0: time.sleep(SerialGrabber_Settings.reader_error_sleep) continue if self.startup_ignore_threshold_milliseconds > 0 and (get_millis() - start) <= self.startup_ignore_threshold_milliseconds: self.logger.warn("Dropping data received inside startup threshold.") continue if SerialGrabber_Settings.drop_carriage_return: current = current.replace("\r", "") self.transaction_extractor.write(current) except Exception, e: self.counter.error() import traceback traceback.print_exc() if self.stream is None: time.sleep(SerialGrabber_Settings.reader_error_sleep)
def make_payload(data, binary=False): return { constants.payload: data, constants.timep: get_millis(), constants.binary: binary }
def get_name(self, name="archive"): if self.filename_roller is not None: return self.filename_roller.calculate_output_name("%s_{ts}.json"%name, get_millis()) return "%s.json" % name