def handle_exception(self, e, log_message=None): logger.info("{}: {}".format(log_message, e)) if self.reraise: raise e if isinstance(e, AuthenticationError): # exit now since there is nothing we can do without login raise e
def untar(self, filename, delete_tar=True, extract_path=None): extract_path = extract_path or '.' logger.info("Untarring the contents of the file ...") tar = tarfile.open(filename) tar.extractall(extract_path) tar.close() if delete_tar: logger.info("Cleaning up the tar file ...") os.remove(filename) return filename
def get_datasets(self, page=1): try: response = self.transport.get(self._get_http_url()) return self.prepare_list_results(response.json(), page, DatasetConfig) except PolyaxonClientException as e: if isinstance(e, AuthenticationError): # exit now since there is nothing we can do without login raise e logger.info("Error while retrieving datasets: %s", e.message) return []
def download_tar(self, url, untar=True, delete_tar=False): """ Download and optionally untar the tar file from the given url """ try: logger.info("Downloading the tar file to the current directory ...") filename = self.download(url=url, filename='output.tar') if filename and untar: logger.info("Untarring the contents of the file ...") tar = tarfile.open(filename) tar.extractall() tar.close() if delete_tar: logger.info("Cleaning up the tar file ...") os.remove(filename) return filename except ERRORS_MAPPING['base'] as e: logger.info("Download URL ERROR! %s", e.message) return False
def _on_close(ws): logger.info('Session ended')
def _on_error(ws, error): if isinstance(error, (KeyboardInterrupt, SystemExit)): logger.info('Quitting... The session will be running in the background.') else: logger.debug('Termination cause: %s', error) logger.debug('Session disconnected.')
def _on_error(self, ws, error): if isinstance(error, (KeyboardInterrupt, SystemExit)): logger.info('Quitting... The session will be running in the background.') else: logger.info('An error occurred.')
def _on_error(self, ws, error): print('error') if isinstance(error, (KeyboardInterrupt, SystemExit)): logger.info('Quitting session, will be running in the background.') else: self.handle_exception(error, 'End session')