-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
42 lines (35 loc) · 1.06 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import yaml
import os
CONFIG_FILE = 'config.yml'
def read():
if not os.path.isfile(CONFIG_FILE):
with open(CONFIG_FILE, 'w') as config_file:
write_default_config(config_file)
print(f'{config_file.name} created, configure it.')
exit(0)
with open(CONFIG_FILE, 'r') as config_file:
return yaml.load(config_file, yaml.FullLoader)
def write_default_config(config_file):
config = {
"influx_db": {
"host": 'localhost',
"port": 8086,
"username": 'root',
"password": 'root',
"database": '_internal'
},
"servers": [
{
'host': 'mc.hypixel.net',
'port': 25565,
'timeout': 1,
'tags': {
'server_name': 'Hypixel',
'server_type': 'mg',
'server_region': 'US'
}
}
],
"ping_period": 1
}
yaml.dump(config, config_file, indent=2, allow_unicode=True, sort_keys=False)