Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sys.exit(0)
try:
with TelemetryNote(config_dir) as telemetry_note:
telemetry_note.touch()
collection = RecordsCollection(telemetry_note.get_last_sent(), config_dir)
collection.snapshot_and_read()
client = CliTelemetryClient()
for each in collection:
client.add(each, flush=True)
client.flush(force=True)
telemetry_note.update_telemetry_note(collection.next_send)
except portalocker.AlreadyLocked:
# another upload process is running.
logger.info('Lock out from note file under %s which means another process is running. Exit 0.', config_dir)
sys.exit(0)
except IOError as err:
logger.warning('Unexpected IO Error %s. Exit 1.', err)
sys.exit(1)
except Exception as err: # pylint: disable=broad-except
logger.error('Unexpected Error %s. Exit 2.', err)
logger.exception(err)
sys.exit(2)
except IndexError:
sys.exit(1)
def __enter__(self):
try:
return self._lock.__enter__()
except portalocker.AlreadyLocked:
raise FailedToLock("Failed to lock [{0}]".format(self._name))