示例#1
0
    def change_replay_visibility(game_hash: str,
                                 visibility: GameVisibilitySetting,
                                 user_id='',
                                 release_date=None) -> 'ReplayVisibility':
        can_change = PlayerWrapper.have_permission_to_change_game(game_hash, user_id)
        if can_change:
            try:
                apply_game_visibility_explicit(user_id, visibility, release_date, game_hash)
            except CalculatedError as e:
                log_error(e)
                raise e
        else:
            log_error(AuthorizationException())

        return ReplayVisibility(game_hash, visibility)
示例#2
0
def apply_game_visibility(query_params=None, game_id=None, game_exists=True) -> Exception:
    if query_params is None:
        return None
    if 'visibility' not in query_params:
        return None

    player_id = query_params['player_id']
    visibility = query_params['visibility']
    try:
        release_date = query_params['release_date']
    except KeyError:
        release_date = None

    try:
        can_change = PlayerWrapper.have_permission_to_change_game(game_id, player_id)
    except ReplayNotFound:
        can_change = not game_exists

    if can_change:
        return apply_game_visibility_explicit(player_id, visibility, release_date, game_id)
    raise AuthorizationException()
def apply_game_visibility(query_params=None,
                          game_id=None,
                          game_exists=True,
                          proto_game=None) -> Exception:

    # if it is a custom lobby we should try and fake it being a private game so scrims are not published.
    if (not game_exists and proto_game is not None and
            proto_game.game_metadata.playlist == Playlist.CUSTOM_LOBBY.value
            and query_params is not None and 'player_id' in query_params):
        query_params = {
            'player_id': query_params['player_id'],
            'visibility': GameVisibilitySetting.PRIVATE
        }

    if query_params is None:
        return None
    if 'visibility' not in query_params:
        return None

    player_id = query_params['player_id']
    visibility = query_params['visibility']
    try:
        release_date = query_params['release_date']
    except KeyError:
        release_date = None

    try:
        can_change = PlayerWrapper.have_permission_to_change_game(
            game_id, player_id)
    except ReplayNotFound:
        can_change = not game_exists

    if can_change:
        return apply_game_visibility_explicit(player_id, visibility,
                                              release_date, game_id)
    raise AuthorizationException()
示例#4
0
    TrainingPackCreation = None
    print("Missing config or AES Key and CRC, not creating training packs")

try:
    from backend.tasks.training_packs.training_packs import create_pack_from_replays
except:
    pass

celery = Celery(__name__, broker=celeryconfig.broker_url)


def create_celery_config():
    celery.config_from_object(celeryconfig)


player_wrapper = PlayerWrapper(limit=10)
player_stat_wrapper = PlayerStatWrapper(player_wrapper)


@celery.on_after_configure.connect
def setup_periodic_tasks(sender, **kwargs):
    sender.add_periodic_task(60 * 60 * 24 * 3,
                             calc_global_stats.s(),
                             name='calculate global stats every 3 days')
    sender.add_periodic_task(60 * 60 * 24,
                             calc_global_dists.s(),
                             name='calculate global dists every day')
    sender.add_periodic_task(60 * 60 * 24,
                             calc_leaderboards.s(),
                             name='calculate leaderboards every day')
    sender.add_periodic_task(60 * 60 * 24 * 3,