yfrake.__main__   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 0
1
# ==================================================================================== #
2
#    __main__.py - This file is part of the YFrake package.                            #
3
# ------------------------------------------------------------------------------------ #
4
#                                                                                      #
5
#    MIT License                                                                       #
6
#                                                                                      #
7
#    Copyright (c) 2022 Mattias Aabmets                                                #
8
#                                                                                      #
9
#    Permission is hereby granted, free of charge, to any person obtaining a copy      #
10
#    of this software and associated documentation files (the "Software"), to deal     #
11
#    in the Software without restriction, including without limitation the rights      #
12
#    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell         #
13
#    copies of the Software, and to permit persons to whom the Software is             #
14
#    furnished to do so, subject to the following conditions:                          #
15
#                                                                                      #
16
#    The above copyright notice and this permission notice shall be included in all    #
17
#    copies or substantial portions of the Software.                                   #
18
#                                                                                      #
19
#    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR        #
20
#    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,          #
21
#    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE       #
22
#    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER            #
23
#    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,     #
24
#    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE     #
25
#    SOFTWARE.                                                                         #
26
#                                                                                      #
27
# ==================================================================================== #
28
from .server.runner import server_runner
29
from .config.config import ConfigSingleton
30
from .config import utils
31
import asyncio
32
33
34
# ==================================================================================== #
35
if __name__ == '__main__':
36
    args = utils.get_runtime_args()
37
    run_server = args.get('run_server')
38
    config_file = args.get('config_file')
39
40
    if config_file == 'here':
41
        config_file = utils.get_cwd_config_path()
42
        if not config_file.exists():
43
            utils.copy_default_config_to(config_file)
44
45
    if run_server is True:
46
        config = ConfigSingleton()
47
        config.file = config_file
48
        coro = server_runner(run_forever=True)
49
        asyncio.run(coro)
50