#!/usr/bin/python import os import sys system_directory = os.path.dirname(os.path.abspath(__file__)) sys.path.append(system_directory + "/imports") username = sys.argv[1] permission_level = int(sys.argv[2]) from rayage.database.User import User from rayage.database.SessionFactory import SessionFactory session = SessionFactory() try: user = User.get_user(username) user.permission_level = permission_level session.add(user) session.commit() print "Successfully set permission level for user '{}' to {}.".format(user.username, user.permission_level) finally: session.close()
#!/usr/bin/python import os import sys import random system_directory = os.path.dirname(os.path.abspath(__file__)) sys.path.append(system_directory + "/imports") #from names import names as usernames from names_from_home_directories import names as usernames from rayage.database.User import User from rayage.database.SessionFactory import SessionFactory import constants session = SessionFactory() try: for username in usernames: permission_level = constants.PERMISSION_LEVEL_USER user = User(username, permission_level) session.add(user) session.commit() finally: session.close()