docs: def _upload_file_safely(fileinfo, remote_dir):
      """attempts to upload a local file to FlashAir,
      tries to remove the remote file if interrupted by any error"""
      try:
          upload.upload_file(fileinfo.path, remote_dir=remote_dir)
      except BaseException as e:
          logger.warning("{} interrupted writing {} -- "
                         "cleaning up partial remote file".format(
                         e.__class__.__name__, fileinfo.path))
          upload.delete_file(fileinfo.path)
          raise e