def main(): commands = ['role-add', 'role-rm', 'list', 'add'] p = argparse.ArgumentParser(description='rz-cli tool. You must provide a command, one of:\n{}'.format(commands)) p.add_argument('--config-dir', help='path to Rhizi config dir', default='res/etc') p.add_argument('--user-db-path', help='path to user_db (ignore config)') p.add_argument('--init-user-db', help='init user db', action='store_const', const=True) p.add_argument('--user-db-init-file', help='user_db db initialization file in \'user,pw\' format') p.add_argument('--email', help='email of user to operate on') p.add_argument('--role', help='role to add or remove to/from user, i.e. admin or user') p.add_argument('--first-name', help="first name for added user") p.add_argument('--last-name', help='last name for added user') p.add_argument('--username', help='username for added user') args, rest = p.parse_known_args() illegal = False if len(rest) != 1: print("only one non argument parameter expected") illegal = True elif rest[0] not in commands: print("command not in {}".format(commands)) illegal = True elif rest[0] in ['role-add', 'role-rm'] and not args.email: print("command {} requires an email argument".format(command)) illegal = True elif rest[0] == 'add' and None in set([args.first_name, args.last_name, args.username]): print("missing one of first-name, last-name or username for user addition") illegal = True if illegal: p.print_help() raise SystemExit command = rest[0] cfg = init_config(args.config_dir) user_db_path = args.user_db_path if args.user_db_path is not None else cfg.user_db_path if args.init_user_db: init_pw_db(cfg, args.user_db_init_file, user_db_path) exit(0) if command == 'role-add': role_add(user_db_path, args.email, args.role) elif command == 'role-rm': role_rm(user_db_path, args.email, args.role) elif command == 'list': list_users(user_db_path) elif command == 'add': print("please enter password:") password = getpass() add_user(user_db_path=user_db_path, cfg=cfg, email=args.email, password=password, first=args.first_name, last=args.last_name, username=args.username)
def __init__(self, config_dir): cfg = init_config(config_dir) kernel = RZ_Kernel() db_ctl = dbc.DB_Controller(cfg.db_base_url) kernel.db_ctl = db_ctl user_db = Fake_User_DB() webapp = init_webapp(cfg, kernel) webapp.user_db = user_db kernel.db_op_factory = webapp # assist kernel with DB initialization kernel.start() time.sleep(0.1) self.kernel = kernel
# # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. #!/usr/bin/python import cgitb from flup.server.fcgi import WSGIServer import os import sys from rz_kernel import RZ_Kernel import rz_server # sys.path.insert(0, '/srv/www/rhizi/rhizi.net/src-py') # enable debugging cgitb.enable() if __name__ == '__main__': cfg = rz_server.init_config(cfg_dir='/etc/rhizi') log = rz_server.init_log(cfg) kernel = RZ_Kernel() webapp = rz_server.init_webapp(cfg, kernel) ws_srv = rz_server.init_ws_interface(cfg, kernel, webapp) log.info('launching webapp via flup.server.fcgi.WSGIServer') WSGIServer(ws_srv).run()
def main(): commands = ['role-add', 'role-rm', 'list', 'add'] p = argparse.ArgumentParser( description='rz-cli tool. You must provide a command, one of:\n{}'. format(commands)) p.add_argument('--config-dir', help='path to Rhizi config dir', default='res/etc') p.add_argument('--user-db-path', help='path to user_db (ignore config)') p.add_argument('--init-user-db', help='init user db', action='store_const', const=True) p.add_argument('--user-db-init-file', help='user_db db initialization file in \'user,pw\' format') p.add_argument('--email', help='email of user to operate on') p.add_argument( '--role', help='role to add or remove to/from user, i.e. admin or user') p.add_argument('--first-name', help="first name for added user") p.add_argument('--last-name', help='last name for added user') p.add_argument('--username', help='username for added user') args, rest = p.parse_known_args() illegal = False if len(rest) != 1: print("only one non argument parameter expected") illegal = True elif rest[0] not in commands: print("command not in {}".format(commands)) illegal = True elif rest[0] in ['role-add', 'role-rm'] and not args.email: print("command {} requires an email argument".format(command)) illegal = True elif rest[0] == 'add' and None in set( [args.first_name, args.last_name, args.username]): print( "missing one of first-name, last-name or username for user addition" ) illegal = True if illegal: p.print_help() raise SystemExit command = rest[0] cfg = init_config(args.config_dir) user_db_path = args.user_db_path if args.user_db_path is not None else cfg.user_db_path if args.init_user_db: init_pw_db(cfg, args.user_db_init_file, user_db_path) exit(0) if command == 'role-add': role_add(user_db_path, args.email, args.role) elif command == 'role-rm': role_rm(user_db_path, args.email, args.role) elif command == 'list': list_users(user_db_path) elif command == 'add': print("please enter password:") password = getpass() add_user(user_db_path=user_db_path, cfg=cfg, email=args.email, password=password, first=args.first_name, last=args.last_name, username=args.username)
# along with this program. If not, see <http://www.gnu.org/licenses/>. #!/usr/bin/python import cgitb from flup.server.fcgi import WSGIServer import os import sys from rz_kernel import RZ_Kernel import rz_server # sys.path.insert(0, '/srv/www/rhizi/rhizi.net/src-py') # enable debugging cgitb.enable() if __name__ == '__main__': cfg = rz_server.init_config(cfg_dir='/etc/rhizi') log = rz_server.init_log(cfg) kernel = RZ_Kernel() webapp = rz_server.init_webapp(cfg, kernel) ws_srv = rz_server.init_ws_interface(cfg, kernel, webapp) log.info('launching webapp via flup.server.fcgi.WSGIServer') WSGIServer(ws_srv).run()