How to use the ndlib.ndtype.NOT_PROPAGATED function in ndlib

To help you get started, we’ve selected a few ndlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neurodata / ndstore / webservices / ndwsrest.py View on Github external
# here value = {NOT_PROPAGATED, UNDER_PROPAGATION} not {PROPAGATED}
  try:
    (token, channel_list, value_list) = re.match("(\w+)/([\w+,]+)/setPropagate/([\d+,]+)/$", webargs).groups()
  except Exception as e:
    logger.error("Illegal setPropagate request. Wrong format {}. {}".format(webargs, e))
    raise NDWSError("Illegal setPropagate request. Wrong format {}. {}".format(webargs, e))
    
  # pattern for using contexts to close databases. get the project
  proj = NDProject.fromTokenName(token)
  
  for channel_name in channel_list.split(','):
    ch = proj.getChannelObj(channel_name)
    
    value = value_list[0]
    # If the value is to be set under propagation and the project is not under propagation
    if int(value) == UNDER_PROPAGATION and ch.propagate == NOT_PROPAGATED:
      # and is not read only
      if ch.readonly == READONLY_FALSE:
        ch.propagate = UNDER_PROPAGATION
        from sd.tasks import propagate
        # then call propagate
        propagate(token, channel_name)
        #propagate.delay(token, channel_name)
      else:
        logger.error("Cannot Propagate this project. It is set to Read Only.")
        raise NDWSError("Cannot Propagate this project. It is set to Read Only.")
    # if the project is Propagated already you can set it to under propagation
    elif int(value) == UNDER_PROPAGATION and ch.propagate == PROPAGATED:
      logger.error("Cannot propagate a project which is propagated. Set to Not Propagated first.")
      raise NDWSError("Cannot propagate a project which is propagated. Set to Not Propagated first.")
    # If the value to be set is not propagated
    elif int(value) == NOT_PROPAGATED:
github neurodata / ndstore / webservices / ndwsrest.py View on Github external
# if the project is Propagated already you can set it to under propagation
    elif int(value) == UNDER_PROPAGATION and ch.propagate == PROPAGATED:
      logger.error("Cannot propagate a project which is propagated. Set to Not Propagated first.")
      raise NDWSError("Cannot propagate a project which is propagated. Set to Not Propagated first.")
    # If the value to be set is not propagated
    elif int(value) == NOT_PROPAGATED:
      # and the project is under propagation then throw an error
      if ch.propagate == UNDER_PROPAGATION:
        logger.error("Cannot set this value. Project is under propagation.")
        raise NDWSError("Cannot set this value. Project is under propagation.")
      # and the project is already propagated and set read only then throw error
      elif ch.propagate == PROPAGATED and ch.readonly == READONLY_TRUE:
        logger.error("Cannot set this Project to unpropagated. Project is Read only")
        raise NDWSError("Cannot set this Project to unpropagated. Project is Read only")
      else:
        ch.propagate = NOT_PROPAGATED
    # cannot set a project to propagated via the RESTful interface
    else:
      logger.error("Invalid Value {} for setPropagate".format(value))
      raise NDWSError("Invalid Value {} for setPropagate".format(value))
github neurodata / ndstore / webservices / ndwsrest.py View on Github external
# and is not read only
      if ch.readonly == READONLY_FALSE:
        ch.propagate = UNDER_PROPAGATION
        from sd.tasks import propagate
        # then call propagate
        propagate(token, channel_name)
        #propagate.delay(token, channel_name)
      else:
        logger.error("Cannot Propagate this project. It is set to Read Only.")
        raise NDWSError("Cannot Propagate this project. It is set to Read Only.")
    # if the project is Propagated already you can set it to under propagation
    elif int(value) == UNDER_PROPAGATION and ch.propagate == PROPAGATED:
      logger.error("Cannot propagate a project which is propagated. Set to Not Propagated first.")
      raise NDWSError("Cannot propagate a project which is propagated. Set to Not Propagated first.")
    # If the value to be set is not propagated
    elif int(value) == NOT_PROPAGATED:
      # and the project is under propagation then throw an error
      if ch.propagate == UNDER_PROPAGATION:
        logger.error("Cannot set this value. Project is under propagation.")
        raise NDWSError("Cannot set this value. Project is under propagation.")
      # and the project is already propagated and set read only then throw error
      elif ch.propagate == PROPAGATED and ch.readonly == READONLY_TRUE:
        logger.error("Cannot set this Project to unpropagated. Project is Read only")
        raise NDWSError("Cannot set this Project to unpropagated. Project is Read only")
      else:
        ch.propagate = NOT_PROPAGATED
    # cannot set a project to propagated via the RESTful interface
    else:
      logger.error("Invalid Value {} for setPropagate".format(value))
      raise NDWSError("Invalid Value {} for setPropagate".format(value))