Best Python code snippet using localstack_python
kinesis_connector.py
Source:kinesis_connector.py
...134 return not self._stop_event.is_set()135 @classmethod136 def get_log_level_names(cls, min_level):137 return [logging.getLevelName(lvl) for lvl in LOG_LEVELS if lvl >= min_level]138 def get_logger_for_level_in_log_line(self, line):139 level = self.log_level140 for lvl in LOG_LEVELS:141 if lvl >= level:142 level_name = logging.getLevelName(lvl)143 if re.match(r'.*(%s):.*' % level_name, line):144 return getattr(self.logger, level_name.lower())145 return None146 def notify_subscribers(self, line):147 for subscriber in self.log_subscribers:148 try:149 if re.match(subscriber.regex, line):150 subscriber.update(line)151 except Exception as e:152 LOGGER.warning('Unable to notify log subscriber: %s' % e)153 def start_reading(self, params):154 for line in self._tail(params['file']):155 # notify subscribers156 self.notify_subscribers(line)157 if self.log_level > 0:158 # add line to buffer159 self.buffer.append(line)160 if len(self.buffer) >= self.buffer_size:161 logger_func = None162 for line in self.buffer:163 if re.match(self.filter_regex, line):164 logger_func = self.get_logger_for_level_in_log_line(line)165 break166 if logger_func:167 for buffered_line in self.buffer:168 logger_func(buffered_line)169 self.buffer = []170 def _tail(self, file):171 with open(file) as f:172 while self.running:173 line = f.readline()174 if line: # empty if at EOF175 yield line.replace('\n', '')176 else:177 time.sleep(0.1)178 def stop(self, quiet=True):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!