Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Include magic in utils
  • Loading branch information
strycore committed Dec 15, 2021
1 parent 51a07db commit fbdafa6
Show file tree
Hide file tree
Showing 2 changed files with 427 additions and 26 deletions.
27 changes: 1 addition & 26 deletions lutris/util/game_finder.py
@@ -1,27 +1,9 @@
"""Automatically detects game executables in a folder"""
import os

from lutris.util import system
from lutris.util import magic, system
from lutris.util.log import logger

try:
import magic
MAGIC_AVAILABLE = True
except ImportError:
MAGIC_AVAILABLE = False
magic = None


if not MAGIC_AVAILABLE:
logger.error("Magic not available. Unable to automatically find game executables. Please install python-magic")
else:
if not hasattr(magic, "from_file"):
if hasattr(magic, "detect_from_filename"):
magic.from_file = lambda f: magic.detect_from_filename(f).name # pylint: disable=no-member
else:
logger.error("Your version of python-magic is too old.")
MAGIC_AVAILABLE = False


def is_excluded_elf(filename):
excluded = (
Expand All @@ -34,9 +16,6 @@ def is_excluded_elf(filename):

def find_linux_game_executable(path, make_executable=False):
"""Looks for a binary or shell script that launches the game in a directory"""
if not MAGIC_AVAILABLE:
logger.warning("Magic not available. Not finding Linux executables")
return ""

for base, _dirs, files in os.walk(path):
candidates = {}
Expand Down Expand Up @@ -98,10 +77,6 @@ def is_excluded_exe(filename):


def find_windows_game_executable(path):
if not MAGIC_AVAILABLE:
logger.warning("Magic not available. Not finding Windows executables")
return ""

for base, _dirs, files in os.walk(path):
candidates = {}
if is_excluded_dir(base):
Expand Down

0 comments on commit fbdafa6

Please sign in to comment.