当前位置: 首页>>代码示例>>Python>>正文


Python DockerBackend类代码示例

本文整理汇总了Python中DockerBackend的典型用法代码示例。如果您正苦于以下问题:Python DockerBackend类的具体用法?Python DockerBackend怎么用?Python DockerBackend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DockerBackend类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: user_box

def user_box(the_user):
    which_user = User.query.filter(User.name == str(the_user)).first()
    if current_user.__name__ is 'AnonymousUser':
        return redirect(url_for("index"))
    if which_user is None or current_user is None:
        return redirect(url_for("index"))
    login_user(which_user)
    email_domain = which_user.email.split("@", 1)[1]
    if email_domain == 'demo.com':
        demo = True
    else:
        demo = False
    try:
        port_4000 = urllib2.urlopen(str(request.url) + '/website')
        port_4000 = True
        print "port 4000 website found"
    except Exception:
        print "no port 4000 site"
        port_4000 = False
    time_left = which_user.dhbox_duration - DockerBackend.how_long_up(which_user.name)
    time_left = DockerBackend.display_time(time_left)
    resp = make_response(render_template('dhbox.html',
                     user=the_user,
                     apps=filter(lambda app: app.get('hide', False) != True, all_apps),
                     demo=demo,
                     time_left=time_left,
                     bootstrap_container='container-fluid',
                     fixed_scroll='fixed_scroll',
                     port_4000=port_4000
                     )
                 )
    return resp
开发者ID:DH-Box,项目名称:dhbox,代码行数:32,代码来源:dhbox.py

示例2: demonstration

def demonstration():
    username = 'demo' + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    demo_user_object = user_datastore.create_user(email=username + '@demo.com', name=username, password='demo', dhbox_duration=3600)
    db.session.commit()
    login_user(demo_user_object)
    DockerBackend.demo_dhbox(username)
    return redirect('/dhbox/' + username)
开发者ID:DH-Box,项目名称:dhbox,代码行数:7,代码来源:dhbox.py

示例3: start_over

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,代码行数:7,代码来源:manage.py

示例4: kill_dhbox

def kill_dhbox():
    the_next = request.form['next']
    user = request.form['user']
    DockerBackend.kill_dhbox(user)
    delete_user(user)
    flash(message='DH Box and username deleted.', category='alert-success')
    return redirect(url_for(the_next) or url_for("index"))
开发者ID:smythp,项目名称:dhbox,代码行数:7,代码来源:dhbox.py

示例5: app_box

def app_box(the_user, app_name):
    which_user = User.query.filter(User.name == str(the_user)).first()
    dhbox_username = which_user.name
    which_app = all_apps[app_name]
    port_info = DockerBackend.get_container_port(dhbox_username, which_app)
    hostname = DockerBackend.get_hostname()
    location = hostname + ":" + port_info
    return redirect('http://' + location)
开发者ID:dsiercks,项目名称:dhbox,代码行数:8,代码来源:dhbox.py

示例6: admin

def admin():
    containers = User.query.all()
    containers_list = []
    for container in containers:
        uptime = DockerBackend.how_long_up(container.name)
        time_left = DockerBackend.check_if_over_time(container)
        time_left = DockerBackend.display_time(time_left)
        containers_list.append({'name': container.name, 'uptime': uptime, 'time_left': time_left})
    return render_template('admin.html', containers=containers_list)
开发者ID:DH-Box,项目名称:dhbox,代码行数:9,代码来源:dhbox.py

示例7: user_box

def user_box(the_user):
    which_user = User.query.filter(User.name == str(the_user)).first()
    if which_user is None:
        return redirect(url_for("index"))
    if current_user.name is not which_user.name:
        return redirect(url_for("index"))
    dhbox_username = which_user.name
    port_info = DockerBackend.get_all_exposed_ports(dhbox_username)
    hostname = DockerBackend.get_hostname()
    resp = make_response(render_template('my_dhbox.html', user=the_user, apps=all_apps))
    return resp
开发者ID:dsiercks,项目名称:dhbox,代码行数:11,代码来源:dhbox.py

示例8: app_box

def app_box(the_user, app_name):
    which_user = User.query.filter(User.name == str(the_user)).first()
    dhbox_username = which_user.name
    app_port = get_app(app_name)['port']
    port_info = DockerBackend.get_container_port(dhbox_username, app_port)
    hostname = DockerBackend.get_hostname()
    location = hostname + ":" + port_info
    if app_name == 'omeka':
        return redirect('http://' + location+'/admin')
    else:
        return redirect('http://' + location)
开发者ID:smythp,项目名称:dhbox,代码行数:11,代码来源:dhbox.py

示例9: kill_dhbox

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)
    DockerBackend.kill_and_remove_user(user)
    flash(message='DH Box and username deleted.', category='alert-success')
    return redirect(url_for(the_next) or url_for("index"))
开发者ID:DH-Box,项目名称:dhbox,代码行数:13,代码来源:dhbox.py

示例10: create_user_and_role

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,代码行数:15,代码来源:dhbox.py

示例11: app_box

def app_box(the_user, app_name):
    which_user = User.query.filter(User.name == str(the_user)).first()
    dhbox_username = which_user.name
    if app_name == 'wordpress':
        app_port = get_app(app_name)['port']
        port_info = DockerBackend.get_container_port(dhbox_username+'_wp', app_port)
    elif app_name == 'website':
        app_port = '4000'
        port_info = DockerBackend.get_container_port(dhbox_username, app_port)
    else:
        app_port = get_app(app_name)['port']
        port_info = DockerBackend.get_container_port(dhbox_username, app_port)
    hostname = DockerBackend.get_hostname()
    location = hostname + ":" + port_info
    return redirect('http://' + location)
开发者ID:DH-Box,项目名称:dhbox,代码行数:15,代码来源:dhbox.py

示例12: create_user_and_role

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,代码行数:15,代码来源:dhbox.py

示例13: demo

def demo():
    username = 'demo' + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    demo_user_object = user_datastore.create_user(email=username + '@demo.com', name=username, password='demo')
    db.session.commit()
    login_user(demo_user_object)
    new_dhbox = DockerBackend.demo_dhbox(username)
    return username
开发者ID:dsiercks,项目名称:dhbox,代码行数:7,代码来源:dhbox.py

示例14: new_dhbox

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,代码行数:25,代码来源:dhbox.py

示例15: new_dhbox

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,代码行数:34,代码来源:dhbox.py


注:本文中的DockerBackend类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。