forked from cameroncros/OctoPrint-DiscordRemote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configtest3.py
27 lines (22 loc) · 880 Bytes
/
configtest3.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
import yaml
config_file = "config.yaml"
octoprint_config = "testenv3/testconfig/config.yaml"
bot_details = {}
try:
with open(config_file, "r") as config:
bot_details = yaml.load(config.read(), Loader=yaml.SafeLoader)
except:
print("To test discord bot posting, you need to create a file "
"called config.yaml in the root directory with your bot "
"details. NEVER COMMIT THIS FILE.")
exit()
octo_config = {}
try:
with open(octoprint_config, "r") as config:
octo_config = yaml.load(config.read(), Loader=yaml.SafeLoader)
except:
print("Run the test.[sh|bat] script first to initialise the testenv.")
exit()
octo_config['plugins']['discordremote'] = bot_details
with open(octoprint_config, "w") as config:
yaml.safe_dump(octo_config, stream=config, default_flow_style=False, indent=2, allow_unicode=True)