Example #1
0
def setPermissions(programName, permissions):
    """ Set the permissions of a given program.
  Warning, will mess up the formatting of the json file.
  """
    permissionsFilePath = paths.getPermissionsFilePath(programName)
    with open(permissionsFilePath, 'w') as file_f:
        json.dump(permissions, file_f, indent=1, separators=(',', ': '))
Example #2
0
def setPermissions(programName,permissions):
  """ Set the permissions of a given program.
  Warning, will mess up the formatting of the json file.
  """
  permissionsFilePath = paths.getPermissionsFilePath(programName)
  with open(permissionsFilePath, 'w') as file_f:
    json.dump(permissions,file_f,indent=1, separators=(',', ': '))
Example #3
0
def getPermissions(programName):
  """ Return the permissions for the given program. """
  # read permissions.json file
  permissionsFilePath = paths.getPermissionsFilePath(programName)
  if permissionsFilePath == None:
    sys.exit("The permissions.json file for the program "+programName+" does not exist.  "+allProgramsMustHavePermissions)
  with open(permissionsFilePath, 'r') as file_f:
    try:
      permissions=json.load(file_f, object_pairs_hook=collections.OrderedDict)
    except ValueError:
      sys.exit("The permissions.json file for the program "+programName+" is not valid json.  "+allProgramsMustHavePermissions)
    return permissions
Example #4
0
def getPermissions(programName):
    """ Return the permissions for the given program. """
    # read permissions.json file
    permissionsFilePath = paths.getPermissionsFilePath(programName)
    if not os.path.exists(permissionsFilePath):
        sys.exit("The permissions.json file for the program " + programName +
                 " does not exist.  " + allProgramsMustHavePermissions)
    with open(permissionsFilePath, 'r') as file_f:
        try:
            permissions = json.load(file_f,
                                    object_pairs_hook=collections.OrderedDict)
        except ValueError:
            sys.exit("The permissions.json file for the program " +
                     programName + " is not valid json.  " +
                     allProgramsMustHavePermissions)
        return permissions