def setMode (key, newval):
  try:
    if (type(newval) is not int):
      newval = int(newval)
  except __HOLE__, e:
    raise UnknownApprovalMode(newval)

  if (newval < 0) or (newval > 2):
    raise UnknownApprovalMode(newval)

  if newval == RULES:
    item = ConfigDB.getConfigItemByKey("geni.openflow.analysis-engine")
    if not item.getValue():
      item.write(True)

  return newval
dataset/ETHPy150Open fp7-ofelia/ocf/ofam/src/src/foam/geni/approval.py/setMode