當前位置: 首頁>>代碼示例>>Python>>正文


Python DockerBackend.setup_new_dhbox方法代碼示例

本文整理匯總了Python中DockerBackend.setup_new_dhbox方法的典型用法代碼示例。如果您正苦於以下問題:Python DockerBackend.setup_new_dhbox方法的具體用法?Python DockerBackend.setup_new_dhbox怎麽用?Python DockerBackend.setup_new_dhbox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DockerBackend的用法示例。


在下文中一共展示了DockerBackend.setup_new_dhbox方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: start_over

# 需要導入模塊: import DockerBackend [as 別名]
# 或者: from DockerBackend import setup_new_dhbox [as 別名]
def start_over():
    """Delete and make a new test DH Box"""
    cleanup()
    response = DockerBackend.kill_dhbox('test')
    response = DockerBackend.kill_dhbox('test_wp')
    DockerBackend.setup_new_dhbox('test', 'password', '[email protected]')
    return response
開發者ID:DH-Box,項目名稱:dhbox,代碼行數:9,代碼來源:manage.py

示例2: create_user_and_role

# 需要導入模塊: import DockerBackend [as 別名]
# 或者: from DockerBackend import setup_new_dhbox [as 別名]
def create_user_and_role():
    first_user = User.query.filter(User.name == str('admin')).first()
    if not first_user:
        user_email = '[email protected]'
        username = 'admin'
        user_pass = app.config['ADMIN_PASS']
        the_user = user_datastore.create_user(email=user_email, name=username, password=user_pass, dhbox_duration=1000000000)
        the_role = user_datastore.create_role(name='admin', description='The administrator')
        user_datastore.add_role_to_user(the_user, the_role)
        db.session.commit()
        try:
            DockerBackend.get_container_info(username)
            print 'already have a container'
        except Exception:
            DockerBackend.setup_new_dhbox(username, user_pass, user_email)
開發者ID:sabo,項目名稱:dhbox,代碼行數:17,代碼來源:dhbox.py

示例3: new_dhbox

# 需要導入模塊: import DockerBackend [as 別名]
# 或者: from DockerBackend import setup_new_dhbox [as 別名]
def new_dhbox():
    users_and_passes = []
    admins_and_passes = []
    form = request.form
    data = {key: request.form.getlist(key)[0] for key in request.form.keys()}
    for key in data:
        users_dict = key
    users_dict = ast.literal_eval(users_dict)
    users = users_dict['users']
    for user in users:
        if 'name' in user:
            if 'email' in user:  # Then is DH Box admin
                name_check = User.query.filter(User.name == user['name']).first()
                email_check = User.query.filter(User.name == user['email']).first()
                if name_check or email_check:
                    print "Username taken. Already has a DH Box."
                    return str('failure')
                admin_user = user['name']
                admin_email = user['email']
                admin_pass = user['pass']
                admin_user_object = user_datastore.create_user(email=admin_email, name=admin_user, password=admin_pass)
                db.session.commit()
                login_user(admin_user_object)
                the_new_dhbox = DockerBackend.setup_new_dhbox(admin_user, admin_pass, admin_email)
    return str('Successfully created a new DH Box.')
開發者ID:smythp,項目名稱:dhbox,代碼行數:27,代碼來源:dhbox.py

示例4: new_dhbox

# 需要導入模塊: import DockerBackend [as 別名]
# 或者: from DockerBackend import setup_new_dhbox [as 別名]
def new_dhbox():
    data = {key: request.form.getlist(key)[0] for key in request.form.keys()}
    for key in data:
        users_dict = key
    users_dict = ast.literal_eval(users_dict)
    users = users_dict['users']
    for user in users:
        if 'name' in user:
            if 'email' in user:  # Then is DH Box admin
                name_check = User.query.filter(User.name == user['name']).first()
                email_check = User.query.filter(User.name == user['email']).first()
                if name_check or email_check:
                    print "Username taken. Already has a DH Box."
                    return str('failure')
                admin_user = user['name']
                admin_email = user['email']
                admin_pass = user['pass']
                if user['duration'] == 'day':
                    duration = 86400
                elif user['duration'] == 'week':
                    duration = 604800
                else:
                    duration = 2592000
                # if user['duration'] == 'week':
                #     duration = 604800
                # elif user['duration'] == 'month':
                #     duration = 2592000
                # else:
                #     duration = 13148730 
                admin_user_object = user_datastore.create_user(email=user['email'], name=user['name'], password=user['pass'], dhbox_duration=duration)
                db.session.commit()
                login_user(admin_user_object)
                the_new_dhbox = DockerBackend.setup_new_dhbox(admin_user, admin_pass, admin_email)
    return str('Successfully created a new DH Box.')
開發者ID:DH-Box,項目名稱:dhbox,代碼行數:36,代碼來源:dhbox.py

示例5: create_user_and_role

# 需要導入模塊: import DockerBackend [as 別名]
# 或者: from DockerBackend import setup_new_dhbox [as 別名]
def create_user_and_role():
    first_user = User.query.filter(User.name == str('steve')).first()
    if not first_user:
        user_email = '[email protected]'
        username = 'steve'
        user_pass = 'password'
        the_user = user_datastore.create_user(email=user_email, name=username, password=user_pass)
        the_role = user_datastore.create_role(name='admin', description='The administrator')
        user_datastore.add_role_to_user(the_user, the_role)
        db.session.commit()
        try:
            is_container = DockerBackend.get_container_info(username)
            print 'already have a container'
        except Exception, e:
            the_new_dhbox = DockerBackend.setup_new_dhbox(username, user_pass, user_email)
開發者ID:smythp,項目名稱:dhbox,代碼行數:17,代碼來源:dhbox.py

示例6: clean_slate

# 需要導入模塊: import DockerBackend [as 別名]
# 或者: from DockerBackend import setup_new_dhbox [as 別名]
def clean_slate():
    """Delete all DH Boxes"""
    cleanup()
    response = DockerBackend.kill_dhbox('test')
    DockerBackend.setup_new_dhbox('test', 'password', '[email protected]')
    return response
開發者ID:DH-Box,項目名稱:dhbox,代碼行數:8,代碼來源:manage.py

示例7: test

# 需要導入模塊: import DockerBackend [as 別名]
# 或者: from DockerBackend import setup_new_dhbox [as 別名]
def test():
    """Build new test DH Box"""
    response = DockerBackend.setup_new_dhbox('test', 'password', '[email protected]')
    return response
開發者ID:DH-Box,項目名稱:dhbox,代碼行數:6,代碼來源:manage.py

示例8: login_user

# 需要導入模塊: import DockerBackend [as 別名]
# 或者: from DockerBackend import setup_new_dhbox [as 別名]
                else:
<<<<<<< HEAD
                    duration = 13148730
=======
                    duration = 2592000
                # if user['duration'] == 'week':
                #     duration = 604800
                # elif user['duration'] == 'month':
                #     duration = 2592000
                # else:
                #     duration = 13148730 
>>>>>>> master
                admin_user_object = user_datastore.create_user(email=user['email'], name=user['name'], password=user['pass'], dhbox_duration=duration)
                db.session.commit()
                login_user(admin_user_object)
                the_new_dhbox = DockerBackend.setup_new_dhbox(admin_user, admin_pass, admin_email)
    return str('Successfully created a new DH Box.')


@app.route('/kill_dhbox', methods=['POST'])
@login_required
def kill_dhbox():
    the_next = request.form.get('next')
    user = request.form.get('user')
    print(user)
    if current_user.has_role("admin"):
        pass
    elif user != current_user.name:
        # If they're not an admin and they're trying to delete a user that isn't them,
        # return a Forbidden error.
        return abort(403)
開發者ID:sabo,項目名稱:dhbox,代碼行數:33,代碼來源:dhbox.py


注:本文中的DockerBackend.setup_new_dhbox方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。