Skip to content

Commit c7da2bc

Browse files
committed
Removed DCS dependency from the bot (for Linux, DCS-less installations)
1 parent bfea3f3 commit c7da2bc

File tree

5 files changed

+35
-24
lines changed

5 files changed

+35
-24
lines changed

core/data/impl/instanceimpl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def set_server(self, server: Optional["Server"]):
9090
self.update_server(server)
9191

9292
def prepare(self):
93+
if 'DCS' not in self.node.locals:
94+
return
9395
# desanitisation of Slmod (if there)
9496
if self.node.locals['DCS'].get('desanitize', True):
9597
# check for SLmod and desanitize its MissionScripting.lua

core/data/impl/nodeimpl.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ async def __aexit__(self, type, value, traceback):
128128
await self.close_db()
129129

130130
async def post_init(self):
131-
await self.get_dcs_branch_and_version()
131+
if 'DCS' in self.locals:
132+
await self.get_dcs_branch_and_version()
132133
self.pool, self.apool = await self.init_db()
133134
try:
134135
self._master = await self.heartbeat()
@@ -229,11 +230,12 @@ def read_locals(self) -> dict:
229230
f"{url.scheme}://{url.username}:SECRET@{url.hostname}:{port}{url.path}?sslmode=prefer"
230231
dirty = True
231232
self.log.info("Database password found, removing it from config.")
232-
password = node['DCS'].pop('dcs_password', node['DCS'].pop('password', None))
233-
if password:
234-
node['DCS']['user'] = node['DCS'].pop('dcs_user', node['DCS'].get('user'))
235-
utils.set_password('DCS', password, self.config_dir)
236-
dirty = True
233+
if 'DCS' in node:
234+
password = node['DCS'].pop('dcs_password', node['DCS'].pop('password', None))
235+
if password:
236+
node['DCS']['user'] = node['DCS'].pop('dcs_user', node['DCS'].get('user'))
237+
utils.set_password('DCS', password, self.config_dir)
238+
dirty = True
237239
if dirty:
238240
with open(config_file, 'w', encoding='utf-8') as f:
239241
yaml.dump(data, f)
@@ -613,18 +615,19 @@ async def register(self):
613615
if not self._public_ip:
614616
self._public_ip = await utils.get_public_ip()
615617
self.log.info(f"- Public IP registered as: {self.public_ip}")
616-
if self.locals['DCS'].get('autoupdate', False):
617-
if not self.locals['DCS'].get('cloud', False) or self.master:
618-
self.autoupdate.start()
619-
else:
620-
branch, old_version = await self.get_dcs_branch_and_version()
621-
try:
622-
new_version = await self.get_latest_version(branch)
623-
if new_version and old_version != new_version:
624-
self.log.warning(
625-
f"- Your DCS World version is outdated. Consider upgrading to version {new_version}.")
626-
except Exception:
627-
self.log.warning("Version check failed, possible auth-server outage.")
618+
if 'DCS' in self.locals:
619+
if self.locals['DCS'].get('autoupdate', False):
620+
if not self.locals['DCS'].get('cloud', False) or self.master:
621+
self.autoupdate.start()
622+
else:
623+
branch, old_version = await self.get_dcs_branch_and_version()
624+
try:
625+
new_version = await self.get_latest_version(branch)
626+
if new_version and old_version != new_version:
627+
self.log.warning(
628+
f"- Your DCS World version is outdated. Consider upgrading to version {new_version}.")
629+
except Exception:
630+
self.log.warning("Version check failed, possible auth-server outage.")
628631

629632
async def unregister(self):
630633
async with self.apool.connection() as conn:

plugins/cloud/commands.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,10 @@ async def register(self):
378378
num_bots = row[0]
379379
num_servers = row[1]
380380
try:
381-
_, dcs_version = await self.node.get_dcs_branch_and_version()
381+
if 'DCS' in self.node.locals:
382+
_, dcs_version = await self.node.get_dcs_branch_and_version()
383+
else:
384+
dcs_version = ""
382385
# noinspection PyUnresolvedReferences
383386
bot = {
384387
"guild_id": self.bot.guilds[0].id,

plugins/funkman/listener.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ class FunkManEventListener(EventListener):
2020
def __init__(self, plugin: Plugin):
2121
super().__init__(plugin)
2222
self.config = self.get_config()
23-
path = self.config['install']
24-
if not os.path.exists(path):
25-
self.log.error(f"FunkMan install path is not correct in your {self.plugin_name}.yaml! "
26-
f"FunkMan will not work.")
23+
path = self.config.get('install')
24+
if not path:
25+
self.log.error(f"FunkMan install path is not set correct in the DEFAULT-section of your "
26+
f"{self.plugin_name}.yaml! FunkMan will not work.")
27+
return
28+
elif not os.path.exists(path):
29+
self.log.error(f"FunkMan is not installed in {path}! FunkMan will not work.")
2730
return
2831
sys.path.append(path)
2932
from funkman.utils.utils import _GetVal

services/servicebus/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, node):
4646
self.servers: dict[str, Server] = ThreadSafeDict()
4747
self.udp_server = None
4848
self.executor = None
49-
if self.node.locals['DCS'].get('desanitize', True):
49+
if 'DCS' in self.locals and self.node.locals['DCS'].get('desanitize', True):
5050
if not self.node.locals['DCS'].get('cloud', False) or self.master:
5151
utils.desanitize(self)
5252
self.loop = asyncio.get_event_loop()

0 commit comments

Comments
 (0)