Skip to content

Commit

Permalink
Merge pull request #21 from Garulf/add-error-logging
Browse files Browse the repository at this point in the history
Add error logging
  • Loading branch information
Garulf authored Jan 20, 2022
2 parents 3b5d135 + 4f44aed commit 0adbf31
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Name": "Steam Search",
"Description": "Search and launch your Steam Game library",
"Author": "Garulf",
"Version": "3.1.0",
"Version": "3.2.0",
"Language": "python",
"Website": "https://github.com/Garulf/Steam-Search",
"IcoPath": "plugin\\icon\\steam-icon.png",
Expand Down
17 changes: 14 additions & 3 deletions plugin/helper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
import logging
import winreg as reg
from winreg import HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE

Expand All @@ -15,6 +16,8 @@
LIBRARY_HERO_SUFFIX = '_library_hero'
STEAMAPPS_FOLDER = 'steamapps'

logger = logging.getLogger(__name__)


class SteamExecutableNotFound(Exception):
def __init__(self, path) -> None:
Expand Down Expand Up @@ -63,7 +66,7 @@ def libraries(self):
try:
library_folders = vdf.load(open(libraries_manifest_path, 'r', encoding='utf-8', errors='ignore'))
except FileNotFoundError:
pass
logging.warning(f'Could not find Steam libraries manifest ("libraryfolders.vdf") at: {libraries_manifest_path}')
else:
if library_folders.get('libraryfolders'):
libraries_key = 'libraryfolders'
Expand Down Expand Up @@ -93,12 +96,20 @@ def __repr__(self):
def games(self):
games = []
for manifest in self._library_path.joinpath(STEAMAPPS_FOLDER).glob('*.acf'):
logger.debug(f'Found manifest: {manifest}')
try:
_game_manifest = vdf.load(open(manifest, 'r', encoding='utf-8', errors='ignore'))
with open(manifest, 'r', encoding='utf-8', errors='ignore') as f:
raw_manifest = f.read()
_game_manifest = vdf.loads(raw_manifest)
game = SteamGame(_game_manifest["AppState"]["appid"], _game_manifest["AppState"]["name"], _game_manifest["AppState"]["installdir"], self._steam_path, self._library_path)
except FileNotFoundError:
pass
logging.warning(f'Could not find game manifest ("{manifest}")')
continue
except SyntaxError:
logging.warning(f'Could not parse game manifest ("{manifest}")')
continue
except KeyError:
logging.warning(f'Unable to parse game manifest ("{manifest}")\n{raw_manifest}')
continue
else:
games.append(game)
Expand Down
1 change: 1 addition & 0 deletions plugin/steam_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class SteamSearch(Flox):

def query(self, query):
self.logger
try:
self._steam = Steam(self.settings.get('steam_path', ''))
if self.settings.get('steam_path') is None or self.settings.get('steam_path') == '':
Expand Down

0 comments on commit 0adbf31

Please sign in to comment.