How to use _write_local method in autotest

Best Python code snippet using autotest_python

data_logging.py

Source:data_logging.py Github

copy

Full Screen

...94 if self._connection_ok:95 self._check_repost_unsent_values()96 self._write_remote(data)97 else:98 self._write_local(data)99 print(data)100 def _check_repost_unsent_values(self):101 if not utils.validate_file_exists(_DB_FAILED_WRITES):102 return103 utils.v_print('Had values which were not successfully sent.')104 all_sent_ok = True105 for data in self._load_locals():106 if self._connection_ok:107 utils.v_print(f"ReSending dropped data: {data}")108 self._write_remote(data)109 else:110 all_sent_ok = False111 self._write_local(data)112 if all_sent_ok:113 print('Successfully pushed, all previously failed db writes, to server.')114 os.remove(_DB_FAILED_WRITES)115 def _write_remote(self, data: utils.DataCapture):116 try:117 self._influx.write_points([118 {119 "time": f'{datetime.fromtimestamp(data.timestamp).strftime("%Y-%m-%dT%T.%f")[:-3]}Z',120 "measurement": "AQ",121 "tags": {122 "runID": _PROG_RUN_ID,123 "hostname": _HOST_NAME124 },125 "fields": {126 "temperature": data.temperature,127 "humidity": data.humidity,128 "pressure": data.pressure,129 "gas": data.gas,130 "quality": data.iaq_index131 }132 }133 ])134 except Exception as err:135 utils.v_print(err)136 self._influx.close()137 self._connection_ok = False138 self._write_local(data)139 def _write_local(self, data: utils.DataCapture):140 self._write_locals([data])141 @staticmethod142 def _write_locals(data: [utils.DataCapture]):143 with open(_DB_FAILED_WRITES, 'ab') as db_backups:144 for val in data:145 pickle.dump(val, db_backups)146 @staticmethod147 def _load_locals() -> [utils.DataCapture]:148 backups = []149 with open(_DB_FAILED_WRITES, 'rb') as db_backups:150 while True:151 try:152 backups.append(pickle.load(db_backups))153 except EOFError:...

Full Screen

Full Screen

logger.py

Source:logger.py Github

copy

Full Screen

...33 """ Stop logging, cleanup resources."""34 pass35 def package_registered(self, package_name):36 """ Notify that a package has been registered."""37 self._write_local("Package %s registered.\n" % package_name)38 def package_downloaded(self, package_name):39 """ Notify that a package has been downloaded."""40 self._write_local("Package %s downloaded.\n" % package_name)41 def package_installed(self, package_name):42 """ Notify that a package has been installed."""43 self._write_local("Package %s installed.\n" % package_name)44 self._write_install("Package %s installed.\n" % package_name)45 def package_removed(self, package_name):46 """ Notify that a package has been removed."""47 self._write_local("Package %s removed.\n" % package_name)48 self._write_install("Package %s removed.\n" % package_name)49 def package_updated(self, package_name):50 """ Notify that a package has been updated."""51 self._write_local("Package %s updated.\n" % package_name)52 self._write_install("Package %s updated.\n" % package_name)53 def set_state(self, state, package_name=""):54 """ Notify the current state."""55 self._write_local("%s %s\n" % (state, package_name))56 def info(self, info_message):57 """ Output some information."""58 self._write_local("%s\n" % info_message)59 def error(self, error_message):60 """ Notify that an error has occurred."""61 self._write_local("%s\n" % error_message)62 self._verbose = True # Switch to verbose on error63 def command(self, command_message):64 """ Notify which command is being executed."""65 self._write_local("%s\n" % command_message)66 def detail(self, detail_message):67 """ Notify some detail."""68 self._write_local("%s\n" % detail_message)69 def _write_local(self, text):70 """ Write information to the local file."""71 file_ = open(self._local_file, "a")72 file_.write(text)73 file_.close()74 def _write_install(self, text):75 """ Write information to the local file."""76 file_ = open(self._install_file, "a")77 file_.write(text)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful