示例#1
0
def initialize():
    try:
        user = input("请输入初始化管理员账户:")
        pwd = input("请输入初始化管理员密码:")
        obj = Admin(user, pwd)
        obj.save()
        return True
    except Exception as e:
        print(e)
def initialize():
    try:
        user = input("请输入初始化用户名: ").strip()
        pwd = getpass.getpass("请输入初始化密码:").strip()
        obj = Admin(user, pwd)
        obj.save()
        return True
    except Exception as e:
        print(e)
示例#3
0
def initialize():
    try:
        user = input('请输入初始化用户名:')
        pwd = getpass.getpass('请输入初始化密码:')
        obj = Admin(user, pwd)
        obj.save()
        return True
    except Exception as e:
        print(e)
示例#4
0
def initialize():
    try:
        username = input("请输入用户名称:")
        password = input("请输入密码:")
        obj = Admin(username, password)
        obj.save()
        return True
    except Exception as e:
        print(e)
示例#5
0
def initialize():
    try:
        user = input('请输入初始化用户名:')
        pwd = input('请输入初始化密码:')
        if len(user) > 0 and len(pwd) > 0:
            obj = Admin(user, pwd)
            obj.save()
            return True
        else:
            print('用户名或密码不能为空')
            return False
    except Exception as e:
        print(e)
示例#6
0
async def admin(context):
    server = context.message.channel.server
    if ("remove" in context.message.content
            and context.message.author.id == server.owner.id):
        for member in context.message.mentions:
            if (member == context.message.author):
                await client.send_message(context.message.channel, "🤔")
                return
            update_admin(member, server, delete=True)
            admins[int(server.id)].remove(int(member.id))
            await client.send_message(context.message.channel,
                                      "Removed %s." % member.display_name)
        return

    if ("list" in context.message.content):
        print("serverid: " + server.id)
        print(admins)
        names = ''
        for userid in admins[int(server.id)]:
            names += (server.get_member(str(userid))).display_name + ' '
        await client.send_message(context.message.channel, names)
        return
    if (context.message.author.id == server.owner.id):
        for member in context.message.mentions:
            admins.setdefault(int(server.id), [])
            if (member.id not in admins[int(server.id)]):
                new_admin = Admin(server.id, member.id, member.name)
                session.add(new_admin)
                admins[int(server.id)].append(int(member.id))
                update_admin(member, server)
                await client.send_message(context.message.channel,
                                          "Added %s." % member.display_name)
    else:
        await client.send_message(context.message.channel,
                                  "Nice try. You have been reported.")
示例#7
0
def login():
    ret = Admin.login()
    if ret:
        if ret['status']:
            print(ret['data'].center(60, '-'))
            main()
        else:
            print(ret['error'].center(60, '-'))
示例#8
0
def login():
    ret = Admin.login()
    if ret:
        if ret['status']:
            print(ret['data'])
            main()
        else:
            print(ret['error'])
示例#9
0
def login_admin():
    print('=================登录管理员系统======================')
    name = input('请输入用户名:')
    pwd = input('请输入密码:')
    ret = Admin.login(name, pwd)
    if ret:
        return True
    else:
        print('登录失败,请重试')
        return False
示例#10
0
    config = ProductionConfig()
    config.SQLALCHEMY_DATABASE_URI = f'sqlite:///{os.path.abspath(args.sql_file)}'
    config.SQLALCHEMY_ECHO = True if args.verbose else False

    # Create app to register database
    app = create_app(config)

    # adds default user to db
    print('Adding admin user', flush=True)
    with app.app_context():
        if len(Admin.query.all()) == 0:
            with open('data/user.json') as f:
                data = json.load(f)
                db.session.add(
                    Admin(
                        data['name'], data['username'],
                        bcrypt.generate_password_hash(
                            data['password']).decode('utf-8')))
                db.session.commit()

    # load attributes groupings
    attribute_groups_path = os.path.join(args.data_directory,
                                         'attribute_groups.csv')
    print(f'Adding attribute groups ({attribute_groups_path})', flush=True)
    if os.path.isfile(attribute_groups_path):
        attribute_groups_df = load_attribute_groups(attribute_groups_path)

        with app.app_context():
            try:
                for i, x in attribute_groups_df.iterrows():
                    db.session.add(
                        QuestionGroup(grouping_key=x.group_id,