mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2026-11-24 03:16:57 +03:00
dashboard.py: mypy lints
Despite it being unused I restored the `logfile` argument to `Dashboard.process()`. It's set in a call to it. Further investigation if/when we do a proper code cleanup.
This commit is contained in:
1 parent
e67e0a03fa
commit
04506899cc
1 file changed
+11
-9
+11
-9
@@ -1,11 +1,13 @@
|
||||
"""Handle the game Status.json file."""
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
import time
|
||||
import tkinter as tk
|
||||
from calendar import timegm
|
||||
from os.path import getsize, isdir, isfile, join
|
||||
from os.path import getsize, isdir, isfile
|
||||
from sys import platform
|
||||
from typing import Any, Dict
|
||||
|
||||
from config import config
|
||||
from EDMCLogging import get_main_logger
|
||||
@@ -32,11 +34,11 @@ class Dashboard(FileSystemEventHandler):
|
||||
|
||||
def __init__(self) -> None:
|
||||
FileSystemEventHandler.__init__(self) # futureproofing - not need for current version of watchdog
|
||||
self.root = None
|
||||
self.currentdir = None # The actual logdir that we're monitoring
|
||||
self.observer = None
|
||||
self.root: tk.Tk = None # type: ignore
|
||||
self.currentdir: str = None # type: ignore # The actual logdir that we're monitoring
|
||||
self.observer: Observer = None # type: ignore
|
||||
self.observed = None # a watchdog ObservedWatch, or None if polling
|
||||
self.status = {} # Current status for communicating status back to main thread
|
||||
self.status: Dict[str, Any] = {} # Current status for communicating status back to main thread
|
||||
|
||||
def start(self, root: tk.Tk, started: int) -> bool:
|
||||
"""
|
||||
@@ -102,7 +104,7 @@ class Dashboard(FileSystemEventHandler):
|
||||
def stop(self) -> None:
|
||||
"""Stop monitoring dashboard."""
|
||||
logger.debug('Stopping monitoring Dashboard')
|
||||
self.currentdir = None
|
||||
self.currentdir = None # type: ignore
|
||||
|
||||
if self.observed:
|
||||
logger.debug('Was observed')
|
||||
@@ -150,7 +152,7 @@ class Dashboard(FileSystemEventHandler):
|
||||
if self.observed:
|
||||
emitter = self.observer._emitter_for_watch[self.observed] # Note: Uses undocumented attribute
|
||||
|
||||
if emitter and emitter.is_alive():
|
||||
if emitter and emitter.is_alive(): # type: ignore
|
||||
return # Watchdog thread still running - stop polling
|
||||
|
||||
self.root.after(self._POLL * 1000, self.poll) # keep polling
|
||||
@@ -165,7 +167,7 @@ class Dashboard(FileSystemEventHandler):
|
||||
# Can get on_modified events when the file is emptied
|
||||
self.process(event.src_path if not event.is_directory else None)
|
||||
|
||||
def process(self) -> None:
|
||||
def process(self, logfile: str = None) -> None:
|
||||
"""
|
||||
Process the contents of current Status.json file.
|
||||
|
||||
@@ -175,7 +177,7 @@ class Dashboard(FileSystemEventHandler):
|
||||
return
|
||||
|
||||
try:
|
||||
with open(join(self.currentdir, 'Status.json'), 'rb') as h:
|
||||
with open(pathlib.Path(self.currentdir) / 'Status.json', 'rb') as h:
|
||||
data = h.read().strip()
|
||||
|
||||
if data: # Can be empty if polling while the file is being re-written
|
||||
|
||||
Reference in new issue
Block a user