Skip to content

Commit

Permalink
Get league executable version + prettier printing
Browse files Browse the repository at this point in the history
  • Loading branch information
lipeeeee committed Feb 2, 2024
1 parent 4c9aa46 commit 0a4e3a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/background_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def start(self) -> None:
def run(self) -> None:
"""Main thread execution"""
while self.running:
print(f"RAN: {self.fn_to_run} with timeout: {self.time_between_runs}")
print(f">> RAN: {self.fn_to_run} with timeout: {self.time_between_runs}")
self.fn_to_run()
sleep(self.time_between_runs)

Expand Down
16 changes: 16 additions & 0 deletions sightstone/lca_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import requests
import urllib3
from requests.models import Response
from win32api import GetFileVersionInfo, LOWORD, HIWORD
from collections import defaultdict
from typing import DefaultDict

Expand Down Expand Up @@ -141,6 +142,19 @@ def riot_auth(self):
"""Riot auth tuple"""
return (self.username, self.riot_token)

@property
def league_version(self) -> tuple[int, int, int, int] | None:
"""Get's league executable file version"""
if not self.connected:
return None
try:
info = GetFileVersionInfo(f"{self.install_dir} Games\\League of Legends\\{self.app_name}.exe", "\\")
ms = info["FileVersionMS"]
ls = info["FileVersionLS"]
return HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls)
except Exception as e:
print(f"ERROR: COULD NOT GET LEAGUE VERSION: {e}")

def build_url(self, path: str) -> str:
"""Build request url"""
return f"{self.protocol}://{self.base_url}:{self.port}/{path}"
Expand All @@ -164,6 +178,7 @@ def listen(self) -> None:
print(f"RIOT-PORT: {self.riot_port}")
print(f"INSTALL-DIR: {self.install_dir}")
print(f"LEAGUE-EXE: {self.app_name}")
print(f"FILEINFO: {self.league_version}")
print("--------")

# Slow down requests if we are connected
Expand All @@ -172,6 +187,7 @@ def listen(self) -> None:
else:
self.listener.time_between_runs = self.LISTEN_TIMEOUT


def parse_cmd_output(self, output: str) -> DefaultDict:
"""Parses cmd output to a dictionary"""
variables: DefaultDict = DefaultDict(lambda: "default")
Expand Down

0 comments on commit 0a4e3a6

Please sign in to comment.