1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-04 01:21:03 +03:00

Merge pull request #2369 from HullSeals/enhancement/1428/timechecker

[1428] Event Timestamp Checker
This commit is contained in:
David Sangrey 2025-02-22 21:04:05 +00:00 committed by GitHub
commit 9f24367d0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 35 additions and 3 deletions

View File

@ -1 +1 @@
3.11.9
3.11

View File

@ -1,6 +1,6 @@
This is the master changelog for Elite Dangerous Market Connector. Entries are in reverse chronological order (latest first).
---
* We currently test against, and package with, Python 3.11.9, 32-bit.
* We currently test against, and package with, Python 3.11, 32-bit.
* As a result, we do not support Windows 7, 8, or 8.1.
* Developers can check the contents of the `.python-version` file
in the source (not distributed with the Windows installer) for the

View File

@ -187,6 +187,12 @@ if __name__ == '__main__': # noqa: C901
'--killswitches-file',
help='Specify a custom killswitches file',
)
parser.add_argument(
'--skip-timecheck',
help='Skips the Time Delta check for processed events',
action='store_true'
)
###########################################################################
args: argparse.Namespace = parser.parse_args()
@ -250,6 +256,9 @@ if __name__ == '__main__': # noqa: C901
for d in conf_module.trace_on:
logger.info(f'marked {d} for TRACE')
if args.skip_timecheck:
config.set_skip_timecheck()
def handle_edmc_callback_or_foregrounding() -> None: # noqa: CCR001
"""Handle any edmc:// auth callback, else foreground an existing window."""
logger.trace_if('frontier-auth.windows', 'Begin...')

View File

@ -201,6 +201,7 @@ class AbstractConfig(abc.ABC):
__auth_force_edmc_protocol = False # Should we force edmc:// protocol ?
__eddn_url = None # Non-default EDDN URL
__eddn_tracking_ui = False # Show EDDN tracking UI ?
__skip_timecheck = False # Skip checking event timestamps?
def __init__(self) -> None:
self.home_path = pathlib.Path.home()
@ -270,6 +271,19 @@ class AbstractConfig(abc.ABC):
"""
return self.__eddn_tracking_ui
def set_skip_timecheck(self):
"""Set the Event Timecheck bool."""
self.__skip_timecheck = True
@property
def skip_timecheck(self) -> bool:
"""
Determine if the Event Timecheck bool is enabled.
:return: bool - Should EDMC check event timechecks?
"""
return self.__skip_timecheck
@property
def app_dir(self) -> str:
"""Return a string version of app_dir."""

View File

@ -14,6 +14,7 @@ import operator
import os
import sys
import tkinter as tk
from datetime import datetime, timedelta
from pathlib import Path
from tkinter import ttk
from typing import Any, Mapping, MutableMapping
@ -331,6 +332,14 @@ def notify_journal_entry(
logger.trace_if('journal.locations', 'Notifying plugins of "Location" event')
error = None
if "timestamp" in entry and not config.skip_timecheck:
# Check that timestamp is recent enough
dt = datetime.strptime(entry["timestamp"], "%Y-%m-%dT%H:%M:%SZ")
if dt > datetime.utcnow() - timedelta(minutes=60):
error = f"Event at {entry['timestamp']} beyond Time Delta of 60 minutes. Skipping."
return error
for plugin in PLUGINS:
journal_entry = plugin._get_func('journal_entry')
if journal_entry:

View File

@ -80,7 +80,7 @@ begin
begin
PowerShellOutputFile := ExpandConstant('{tmp}\PowershellOutput.txt');
// Construct the PowerShell command and capture output to a file
Exec('powershell.exe', '-NoProfile -ExecutionPolicy Bypass -Command "Get-WmiObject -Class Win32_Product | where Name -eq ''Elite Dangerous Market Connector'' | select-object -expandproperty IdentifyingNumber" | Out-File -Encoding ASCII "' + PowerShellOutputFile + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec('powershell.exe', '-NoProfile -Command "Get-WmiObject -Class Win32_Product | where Name -eq ''Elite Dangerous Market Connector'' | select-object -expandproperty IdentifyingNumber" | Out-File -Encoding ASCII "' + PowerShellOutputFile + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
begin
if LoadStringFromFile(PowerShellOutputFile, S) then
S:= Trim(S);