Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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 []
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 def _on_close(ws):
     logger.info('Session ended')
Ejemplo n.º 6
0
 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.')
Ejemplo n.º 7
0
 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.')
Ejemplo n.º 8
0
 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')