Skip to content

Commit 3410c1a

Browse files
committed
New feature "alternate_recording" to work around tacview bug
1 parent 05510b5 commit 3410c1a

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

extensions/tacview/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ MyNode:
3030
tacviewRemoteControlPassword: '' # default
3131
tacviewPlaybackDelay: 600 # default 0, should be 600 for performance reasons
3232
tacviewDataCaptureMode: 8 # As of v1.9.5: default 1, defines at which frame Tacview should update (1 = every frame, 10 = every 10th frame).
33-
target: '<id:112233445566778899>' # optional: channel id or directory
33+
target: '<id:112233445566778899>' # Optional: channel id or directory
3434
```
3535
__Optional__ parameters (will change options.lua if necessary):</br>
3636
* **tacviewExportPath** Sets this as the Tacview export path.

extensions/tacview/extension.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from datetime import datetime
2+
13
import aiofiles
24
import asyncio
35
import os
46
import re
57
import shutil
68
import sys
9+
import tempfile
710

811
from core import Extension, utils, ServiceRegistry, Server, get_translation, InstallException, DISCORD_FILE_SIZE_LIMIT, \
912
Status, PortType, Port
@@ -79,7 +82,13 @@ def __init__(self, server: Server, config: dict):
7982
async def startup(self, *, quiet: bool = False) -> bool:
8083
self.stop_event.clear()
8184
self.stopped.clear()
82-
if self.config.get('target'):
85+
if self.config.get('alternate_recording', False):
86+
asyncio.create_task(
87+
self.start_recording("Tacview-{}-DCS-Host-{}.acmi".format(
88+
datetime.now().strftime("%Y%m%d-%H%M%S"), utils.slugify(self.server.current_mission.name))
89+
)
90+
)
91+
elif self.config.get('target'):
8392
asyncio.create_task(self.check_log())
8493
return await super().startup()
8594

@@ -89,7 +98,10 @@ async def _shutdown(self):
8998

9099
@override
91100
def shutdown(self, *, quiet: bool = False) -> bool:
92-
if self.config.get('target'):
101+
if self.config.get('alternate_recording', False):
102+
self.loop.create_task(self.stop_recording())
103+
return True
104+
elif self.config.get('target'):
93105
self.loop.create_task(self._shutdown())
94106
self.stop_event.set()
95107
return True

extensions/tacview/recorder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ async def _reader_loop(self) -> None:
147147
chunk = await self.reader.read(65536)
148148
except asyncio.IncompleteReadError:
149149
# Remote closed connection
150-
self.log.warning("Connection closed by remote.")
150+
self.log.debug("Tacview connection closed by remote.")
151151
break
152152
if not chunk:
153-
self.log.warning("Connection closed by remote.")
153+
self.log.debug("Tacview connection closed by remote.")
154154
break
155155
await self._ingest(chunk)
156156
finally:

extensions/tacview/schemas/tacview_schema.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ schema;node_tacview_schema:
77
installation: {type: str, nullable: false, range: {min: 1}, func: dir_exists}
88
host: {type: str, nullable: false}
99
show_passwords: {type: bool, nullable: false}
10+
alternate_recording: {type: bool, nullable: false}
1011
tacviewExportPath: {type: str, nullable: false, range: {min: 1}}
1112
tacviewAutoDiscardFlights: {type: int, nullable: false}
1213
tacviewDebugMode: {type: int, nullable: false}
@@ -34,6 +35,7 @@ schema;instance_tacview_schema:
3435
host: {type: str, nullable: false}
3536
log: {type: str, nullable: false}
3637
show_passwords: {type: bool, nullable: false}
38+
alternate_recording: {type: bool, nullable: false}
3739
tacviewExportPath: {type: str, nullable: false}
3840
tacviewAutoDiscardFlights: {type: int, nullable: false}
3941
tacviewDebugMode: {type: int, nullable: false}

0 commit comments

Comments
 (0)