GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( bc5271...0254c9 )
by Michael
01:27
created

signal_handler()   A

Complexity

Conditions 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 4
rs 10
1
#!/usr/bin/env python3
2
"""
3
Usage:
4
    server.py [--nodb | --db TYPE]
5
6
Options:
7
    --nodb      Don't use a database (Use a mock.Mock). Caution: Will break things.
8
    --db TYPE   Use TYPE database driver [default: QMYSQL]
9
"""
10
11
import asyncio
12
0 ignored issues
show
Configuration introduced by
The import aiomeasures could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
13
import logging
14
from logging import handlers
15
import signal
16
import socket
17
0 ignored issues
show
Bug introduced by
The name game does not seem to exist in module server.games.
Loading history...
Configuration introduced by
Unable to import 'games.game' (invalid syntax (<string>, line 187))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
18
from server.game_service import GameService
0 ignored issues
show
Bug introduced by
The name game_stats_service does not seem to exist in module server.stats.
Loading history...
Configuration introduced by
Unable to import 'stats.game_stats_service' (invalid syntax (<string>, line 15))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
19
from server.matchmaker import MatchmakerQueue
0 ignored issues
show
Configuration introduced by
Unable to import 'gameconnection' (invalid syntax (<string>, line 94))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
20
from server.player_service import PlayerService
0 ignored issues
show
Configuration introduced by
Unable to import 'natpacketserver' (invalid syntax (<string>, line 58))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
21
from server.natpacketserver import NatPacketServer
0 ignored issues
show
Configuration introduced by
Unable to import 'lobbyconnection' (invalid syntax (<string>, line 122))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
22
from server.stats.game_stats_service import GameStatsService, EventService, AchievementService
23
from server.api.api_accessor import ApiAccessor
0 ignored issues
show
Configuration introduced by
Unable to import 'servercontext' (invalid syntax (<string>, line 29))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
24
import server
0 ignored issues
show
Configuration introduced by
Unable to import 'player_service' (invalid syntax (<string>, line 114))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
25
import server.config as config
0 ignored issues
show
Configuration introduced by
Unable to import 'game_service' (invalid syntax (<string>, line 53))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
26
from server.config import DB_SERVER, DB_PORT, DB_LOGIN, DB_PASSWORD, DB_NAME
0 ignored issues
show
Configuration introduced by
Unable to import 'ladder_service' (invalid syntax (<string>, line 30))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
27
0 ignored issues
show
Configuration introduced by
Unable to import 'control' (invalid syntax (<string>, line 30))

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
28
if __name__ == '__main__':
29
    logger = logging.getLogger()
30
    stderr_handler = logging.StreamHandler()
31
    logger.addHandler(stderr_handler)
32
    logger.setLevel(logging.DEBUG)
33
34
    try:
35
        def signal_handler(signal, frame):
36
            logger.info("Received signal, shutting down")
37
            if not done.done():
38
                done.set_result(0)
39
40
        loop = asyncio.get_event_loop()
0 ignored issues
show
Bug introduced by
Undefined variable name 'abc' in __all__
Loading history...
41
        done = asyncio.Future()
42
43
        from docopt import docopt
44
        args = docopt(__doc__, version='FAF Server')
45
46
        logger.info("Using StatsD server: ".format(config.STATSD_SERVER))
47
48
        # Make sure we can shutdown gracefully
49
        signal.signal(signal.SIGTERM, signal_handler)
50
        signal.signal(signal.SIGINT, signal_handler)
51
52
        pool_fut = asyncio.async(server.db.connect(host=DB_SERVER,
53
                                                   port=int(DB_PORT),
54
                                                   user=DB_LOGIN,
55
                                                   password=DB_PASSWORD,
56
                                                   maxsize=10,
57
                                                   db=DB_NAME,
58
                                                   loop=loop))
59
        db_pool = loop.run_until_complete(pool_fut)
60
61
        players_online = PlayerService(db_pool)
62
        api_accessor = ApiAccessor()
63
        event_service = EventService(api_accessor)
64
        achievement_service = AchievementService(api_accessor)
65
        game_stats_service = GameStatsService(event_service, achievement_service)
66
67
        natpacket_server = NatPacketServer(addresses=config.LOBBY_NAT_ADDRESSES, loop=loop)
68
        loop.run_until_complete(natpacket_server.listen())
69
        server.NatPacketServer.instance = natpacket_server
70
71
        games = GameService(players_online, game_stats_service)
72
        matchmaker_queue = MatchmakerQueue('ladder1v1', players_online, games)
73
        players_online.ladder_queue = matchmaker_queue
74
75
        ctrl_server = loop.run_until_complete(server.run_control_server(loop, players_online, games))
76
77
        lobby_server = server.run_lobby_server(('', 8001),
78
                                    players_online,
79
                                    games,
80
                                    loop)
81
82
        for sock in lobby_server.sockets:
83
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
84
85
        loop.run_until_complete(done)
86
        loop.close()
87
88
    except Exception as ex:
89
        logger.exception("Failure booting server {}".format(ex))
90