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


Python registry.get_registry函数代码示例

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


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

示例1: create_table

 def create_table():
     result = r.get_registry()['MY_SQL'].query(
         (
             "select * from information_schema.tables where "
             "TABLE_SCHEMA='scoring_system' and table_name='runs';"
         )
     )
     if result != 0:
         return
     query = (
         """CREATE TABLE IF NOT EXISTS runs(
             id INT AUTO_INCREMENT,
             level INT,
             failed_trial BOOLEAN,
             actual_time FLOAT(10,2),
             non_air BOOLEAN,
             furniture BOOLEAN,
             arbitrary_start BOOLEAN,
             return_trip BOOLEAN,
             candle_location_mode BOOLEAN,
             stopped_within_circle BOOLEAN,
             signaled_detection BOOLEAN,
             num_rooms_searched INT,
             kicked_dog BOOLEAN,
             touched_candle INT,
             cont_wall_contact INT,
             ramp_hallway BOOLEAN,
             alt_target BOOLEAN,
             all_candles BOOLEAN,
             used_versa_valve BOOLEAN,
             score FLOAT(10,2),
             robot_id VARCHAR(10),
             PRIMARY KEY (id))
             ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;""")
     r.get_registry()['MY_SQL'].query(query)
开发者ID:jinpyojeon,项目名称:RoboticsContestScoringSystem,代码行数:35,代码来源:runs.py

示例2: create_table

 def create_table():
     result = r.get_registry()['MY_SQL'].query(
         (
             "select * from information_schema.tables where "
             "TABLE_SCHEMA='scoring_system' and table_name='robots';"
         )
     )
     if result != 0:
         return
     query = (
         """CREATE TABLE IF NOT EXISTS robots(
         division VARCHAR(16),
         id VARCHAR(10) UNIQUE,
         volume INT,
         school VARCHAR(100),
         name VARCHAR(100),
         is_unique BOOLEAN,
         used_versa_valve BOOLEAN,
         level INT,
         is_disqualified BOOLEAN,
         passed_inspection BOOLEAN,
         PRIMARY KEY (id))
         ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"""
     )
     r.get_registry()['MY_SQL'].query(query)
     r.get_registry()['MY_SQL'].query(
         ('ALTER TABLE robots ADD INDEX (name), ADD '
          'UNIQUE INDEX (name)')
     )
开发者ID:binay-jana,项目名称:RoboticsContestScoringSystem,代码行数:29,代码来源:robots.py

示例3: robot_detail

def robot_detail(robot_id, inputs=None):
    robot = r.get_registry()['ROBOTS'].get_robot(robot_id)
    if not robot:
        return render_template("not_found.html")

    runs = r.get_registry()['RUNS'].get_runs(robot_id)
    run_levels = [run['id'] for run in runs]

    # check if disqualifited and eligibility to advnace to next level
    eligibility = LevelProgressHandler.get_eligibility_for_next_run(
        runs, robot['level']
    )
    # get current best scores
    best_scores, attempted_levels, total_score, num_successful = (
        ScoreCalculator.get_best_scores(runs)
    )
    return render_template(
        "robot.html",
        attempted_levels=attempted_levels,
        total_score=total_score,
        robot_id=robot_id,
        robot=robot,
        disqualified=eligibility['disqualified'],
        eligible=eligibility['can_level_up'],
        best_scores=best_scores,
        robot_runs=runs,
        applied_factors=[applied_factors(id, robot_id) for id in run_levels],
        inputs=inputs
    )
开发者ID:binay-jana,项目名称:RoboticsContestScoringSystem,代码行数:29,代码来源:main.py

示例4: run

def run():
    load_registry()
    r.get_registry()['MY_SQL'].query(
        'DROP TABLE runs;'
    )
    r.get_registry()['MY_SQL'].query(
        'DROP TABLE robots;'
    )
开发者ID:binay-jana,项目名称:RoboticsContestScoringSystem,代码行数:8,代码来源:delete_tables.py

示例5: applied_factors

def applied_factors(run_id, robot_id):
    query = ("""SELECT * FROM runs where id = %(run_id)s;""")
    data = {
        'run_id': run_id
    }
    run_data = r.get_registry()['MY_SQL'].get(query, data)

    query = ("""SELECT division FROM robots where id = %(robot_id)s;""")
    data = {
        'robot_id': robot_id
    }
    robot_div = r.get_registry()['MY_SQL'].get(query, data).get('division')

    run_level = run_data['level']

    applied_oms = ""
    applied_rf = ""
    applied_pp = ""

    if run_data.get('failed_trial') == 1:
        if run_level == 1 and robot_div in ['junior', 'walking']:
            if (run_data.get('num_rooms_searched', 0) > 0):
                applied_oms += 'Task.search:-30x%d rooms\n' % (run_data.get('num_rooms_searched', 0))
            applied_oms += 'Task.detect:-30\n' if run_data.get('signaled_detection', 0) == 1 else ''
            applied_oms += 'Task.position:-30\n' if run_data.get('stopped_within_circle', 0) == 1 else ''
    else:
        if run_data.get('touched_candle', 0) > 0:
            applied_pp += 'PP.candle=%d\n' % (run_data.get('touched_candle', 0) * 50)
        if run_data.get('cont_wall_contact', 0) > 0:
            applied_pp += 'PP.slide=%dcm/2\n' % (run_data.get('cont_wall_contact', 0))
        applied_pp += 'PP.dog=50\n' if run_data.get('kicked_dog', 0) == 1 else ''

        if run_level == 1:
            applied_oms += 'OM.candle=0.75\n' if run_data.get('candle_location_mode', 0) == 1 else ''

        if run_level in [1,2]:
            applied_oms += 'OM.start=0.8\n' if run_data.get('arbitrary_start', 0) == 1 else ''
            applied_oms += 'OM.return=0.8\n' if run_data.get('return_trip', 0) == 1 else ''
            applied_oms += 'OM.extinguisher=0.75\n' if run_data.get('non_air', 0) == 1 else ''
            applied_oms += 'OM.furniture=0.75\n' if run_data.get('furniture', 0) == 1 else ''

            if run_data.get('num_rooms_searched') == 1:
                applied_rf += 'Room Factor:1\n'
            elif run_data.get('num_rooms_searched') == 2:
                applied_rf += 'Room Factor:0.85\n'
            elif run_data.get('num_rooms_searched') == 3:
                applied_rf += 'Room Factor:0.5\n'
            elif run_data.get('num_rooms_searched') == 4:
                applied_rf += 'Room Factor:0.35\n'

        elif run_level == 3:
            applied_oms += 'OM.Alt_Target=0.6\n' if run_data.get('alt_target', 0) == 1 else ''
            applied_oms += 'OM.Ramp_Hallway=0.9\n' if run_data.get('ramp_hallway', 0) == 1 else ''
            applied_oms += 'OM.All_Candles=0.6\n' if run_data.get('all_candles', 0) == 1 else '' 

    return {'applied_oms': applied_oms, 'applied_rf': applied_rf, 'applied_pp': applied_pp}
开发者ID:binay-jana,项目名称:RoboticsContestScoringSystem,代码行数:56,代码来源:main.py

示例6: set_day

    def set_day(run_id, day):
        query = """UPDATE runs SET
            day = %(day)s
            where id = %(id)s;"""

        data = {
            'day': day,
            'id': run_id
        }
        r.get_registry()['MY_SQL'].insert(query, data)
开发者ID:jinpyojeon,项目名称:RoboticsContestScoringSystem,代码行数:10,代码来源:runs.py

示例7: get

 def get(cls, id):
     redis_key = cls.get_redis_key(id)
     cached_data = r.get_registry()['REDIS'].hgetall(redis_key)
     if cached_data:
         return Question(cached_data)
     query = "SELECT * FROM questions WHERE id=%s"
     result = r.get_registry()['MY_SQL'].get(query, [id])
     if result:
         cls.cache_result(result)
         return Question(result)
     return None
开发者ID:binay-jana,项目名称:geographychallenge,代码行数:11,代码来源:questions.py

示例8: robot_add_run

def robot_add_run(robot_id):
    robot = r.get_registry()['ROBOTS'].get_robot(robot_id)

    if not robot:
        return render_template("not_found.html")

    all_runs = r.get_registry()['RUNS'].get_runs(robot_id)
    if request.method == 'GET':
        # get all previous runs
        return render_template(
            "run.html",
            robot=robot,
            division=get_division_label(robot['division']),
            input=request.args,
            all_runs=all_runs
        )
    # For post request

    # Database query for showing past runs if the POST fails

    all_runs = r.get_registry()['RUNS'].get_runs(robot_id)

    # if invalidate input data
    params_d = bind_params(request.form, robot_id, robot['level'])

    err = validate_params(params_d,
                          robot['level'],
                          robot['division'],
                          robot['name'])

    if err:
        err['ERR'] = True
        params_and_errors = {}
        params_and_errors.update(params_d)
        # leave data already entered unchanged
        params_and_errors.update(err)  # include errors
        return render_template(
            "run.html",
            robot=robot,
            division=get_division_label(robot['division']),
            input=params_and_errors,
            all_runs=all_runs
        )

    # calculate score
    score = get_score(robot, params_d)
    # convert dict values to tuple to prepare to insert to DB
    params_t = convert_to_tuple(params_d, robot_id, score)
    # insert into databse
    r.get_registry()['RUNS'].record_run(*params_t)
    return redirect(url_for('main.robot_detail', robot_id=robot_id))
开发者ID:binay-jana,项目名称:RoboticsContestScoringSystem,代码行数:51,代码来源:main.py

示例9: advance_level

def advance_level(robot_id):
    robot = r.get_registry()['ROBOTS'].get_robot(robot_id)

    if not robot:
        return render_template("not_found.html")

    runs = r.get_registry()['RUNS'].get_runs(robot_id)

    eligible = LevelProgressHandler.get_eligibility_for_next_run(runs, robot['level'])

    if eligible.get('can_level_up') and not eligible['disqualified']:
        r.get_registry()['ROBOTS'].advance_level(robot_id, robot['level'])
        return redirect(url_for('main.robot_add_run', robot_id=robot_id))

    return "Robot not eligible to advance to next level.\n"
开发者ID:binay-jana,项目名称:RoboticsContestScoringSystem,代码行数:15,代码来源:main.py

示例10: advance_level

 def advance_level(robot_id, current_level):
     query = """UPDATE robots SET level = %(level)s where id = %(robot_id)s;"""
     data = {
         'level': current_level + 1,
         'robot_id': robot_id
     }
     return r.get_registry()['MY_SQL'].insert(query, data)
开发者ID:binay-jana,项目名称:RoboticsContestScoringSystem,代码行数:7,代码来源:robots.py

示例11: run

def run():
    # grant all privileges on *.* to [email protected] identified by '9a7123w4982ew3490x23pl34bz' with grant option; # NOQA
    load_registry()
    r.get_registry()['MY_SQL'].query('CREATE DATABASE challenge;')
    r.get_registry()['MY_SQL'].query(
        """CREATE TABLE questions(
            id INT PRIMARY KEY AUTO_INCREMENT,
            name VARCHAR(255),
            prompt VARCHAR(255),
            passing_score INT,
            correct_names LONGTEXT,
            finalized INT DEFAULT 1,
            active INT DEFAULT 1,
            total INT DEFAULT 0
        )"""
    )
开发者ID:binay-jana,项目名称:geographychallenge,代码行数:16,代码来源:load.py

示例12: get_runs_robot_level

 def get_runs_robot_level(robot_id, level):
     query = """SELECT * FROM runs where (robot_id = %(robot_id)s) AND (level = level);"""
     data = {
         'robot_id': robot_id,
         'level': level
     }
     return r.get_registry()['MY_SQL'].get_all(query, data)
开发者ID:jinpyojeon,项目名称:RoboticsContestScoringSystem,代码行数:7,代码来源:runs.py

示例13: scoreboard_lisp

def scoreboard_lisp(level):
    if not level.isdigit():
        return render_template("not_found.html")
    if int(level) not in [1, 2, 3]:
        return render_template("not_found.html")

    robots = r.get_registry()['ROBOTS'].get_all_robots()

    if not robots:
        return render_template("not_found.html")

    # add additional parameters to be displayed on scoreboard
    robots = ScoreBoard.add_scoreboard_params(robots)

    # filter robots
    filtered_robots = ScoreBoard.filter_robots_level(robots, int(level))

    # key used for sorting
    score_name = "LS" + level

    # sort based on name then this level's lowest score
    sorted_robots = sorted(list(filtered_robots), key=lambda k: k['name'])
    sorted_robots = sorted(list(sorted_robots), key=lambda k: k[score_name])

    return render_template(
        "scoreboard_lisp.html",
        robots=sorted_robots,
        level=level,
        score_name=score_name
    )
开发者ID:binay-jana,项目名称:RoboticsContestScoringSystem,代码行数:30,代码来源:main.py

示例14: home

def home():
    robots = r.get_registry()['ROBOTS'].get_all_robots()
    for rb in robots:
        rb['endpoint'] = url_for('main.robot_detail', robot_id=rb['id'])
    return render_template(
        "home.html",
        robots=robots
    )
开发者ID:binay-jana,项目名称:RoboticsContestScoringSystem,代码行数:8,代码来源:main.py

示例15: record_robot

 def record_robot(division,
                  id,
                  volume,
                  school,
                  name,
                  is_unique,
                  used_versa_valve,
                  level,
                  is_disqualified,
                  passed_inspection):
     query = """INSERT INTO robots(
         division,
         id,
         volume,
         school,
         name,
         is_unique,
         used_versa_valve,
         level,
         is_disqualified,
         passed_inspection
     ) VALUES (
         %(division)s,
         %(id)s,
         %(volume)s,
         %(school)s,
         %(name)s,
         %(is_unique)s,
         %(used_versa_valve)s,
         %(level)s,
         %(is_disqualified)s,
         %(passed_inspection)s
     );"""
     data = {
         'division': division,
         'id': id,
         'volume': volume,
         'school': school,
         'name': name,
         'is_unique': is_unique,
         'used_versa_valve': used_versa_valve,
         'level': level,
         'is_disqualified': is_disqualified,
         'passed_inspection': passed_inspection
     }
     r.get_registry()['MY_SQL'].insert(query, data)
开发者ID:binay-jana,项目名称:RoboticsContestScoringSystem,代码行数:46,代码来源:robots.py


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