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=(',', ': '))
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=(',', ': '))
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
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