Skip to content

Commit

Permalink
Merge pull request #2369 from HullSeals/enhancement/1428/timechecker
Browse files Browse the repository at this point in the history
[1428] Event Timestamp Checker
  • Loading branch information
Rixxan authored Feb 22, 2025
2 parents cfcae63 + 1a93396 commit 9f24367
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.9
3.11
2 changes: 1 addition & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 9 additions & 0 deletions EDMarketConnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@
'--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()
Expand Down Expand Up @@ -250,6 +256,9 @@
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...')
Expand Down
14 changes: 14 additions & 0 deletions config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -270,6 +271,19 @@ def eddn_tracking_ui(self) -> bool:
"""
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."""
Expand Down
9 changes: 9 additions & 0 deletions plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion resources/EDMC_Installer_Config_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9f24367

Please sign in to comment.