Merge pull request #179 from kra-mo/geoffreys-dev-branch
Improvements to game executable + better handling of corrupted log files
This commit is contained in:
@@ -47,8 +47,9 @@ class BottlesSourceIterable(SourceIterable):
|
|||||||
"added": added_time,
|
"added": added_time,
|
||||||
"name": entry["name"],
|
"name": entry["name"],
|
||||||
"game_id": self.source.game_id_format.format(game_id=entry["id"]),
|
"game_id": self.source.game_id_format.format(game_id=entry["id"]),
|
||||||
"executable": self.source.executable_format.format(
|
"executable": self.source.make_executable(
|
||||||
bottle_name=entry["bottle"]["name"], game_name=entry["name"]
|
bottle_name=entry["bottle"]["name"],
|
||||||
|
game_name=entry["name"],
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
game = Game(values)
|
game = Game(values)
|
||||||
|
|||||||
@@ -82,9 +82,7 @@ class FlatpakSourceIterable(SourceIterable):
|
|||||||
"added": added_time,
|
"added": added_time,
|
||||||
"name": name,
|
"name": name,
|
||||||
"game_id": self.source.game_id_format.format(game_id=flatpak_id),
|
"game_id": self.source.game_id_format.format(game_id=flatpak_id),
|
||||||
"executable": self.source.executable_format.format(
|
"executable": self.source.make_executable(flatpak_id=flatpak_id),
|
||||||
flatpak_id=flatpak_id
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
game = Game(values)
|
game = Game(values)
|
||||||
|
|
||||||
|
|||||||
@@ -108,9 +108,7 @@ class SubSourceIterable(Iterable):
|
|||||||
"game_id": self.source.game_id_format.format(
|
"game_id": self.source.game_id_format.format(
|
||||||
service=self.service, game_id=app_name
|
service=self.service, game_id=app_name
|
||||||
),
|
),
|
||||||
"executable": self.source.executable_format.format(
|
"executable": self.source.make_executable(runner=runner, app_name=app_name),
|
||||||
runner=runner, app_name=app_name
|
|
||||||
),
|
|
||||||
"hidden": self.source_iterable.is_hidden(app_name),
|
"hidden": self.source_iterable.is_hidden(app_name),
|
||||||
}
|
}
|
||||||
game = Game(values)
|
game = Game(values)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class ItchSourceIterable(SourceIterable):
|
|||||||
"source": self.source.source_id,
|
"source": self.source.source_id,
|
||||||
"name": row[1],
|
"name": row[1],
|
||||||
"game_id": self.source.game_id_format.format(game_id=row[0]),
|
"game_id": self.source.game_id_format.format(game_id=row[0]),
|
||||||
"executable": self.source.executable_format.format(cave_id=row[4]),
|
"executable": self.source.make_executable(cave_id=row[4]),
|
||||||
}
|
}
|
||||||
additional_data = {"online_cover_url": row[3] or row[2]}
|
additional_data = {"online_cover_url": row[3] or row[2]}
|
||||||
game = Game(values)
|
game = Game(values)
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ from src.game import Game
|
|||||||
from src.importer.sources.location import Location, LocationSubPath
|
from src.importer.sources.location import Location, LocationSubPath
|
||||||
from src.importer.sources.source import (
|
from src.importer.sources.source import (
|
||||||
ExecutableFormatSource,
|
ExecutableFormatSource,
|
||||||
SourceIterationResult,
|
|
||||||
SourceIterable,
|
SourceIterable,
|
||||||
|
SourceIterationResult,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ class LegendarySourceIterable(SourceIterable):
|
|||||||
"source": self.source.source_id,
|
"source": self.source.source_id,
|
||||||
"name": entry["title"],
|
"name": entry["title"],
|
||||||
"game_id": self.source.game_id_format.format(game_id=app_name),
|
"game_id": self.source.game_id_format.format(game_id=app_name),
|
||||||
"executable": self.source.executable_format.format(app_name=app_name),
|
"executable": self.source.make_executable(app_name=app_name),
|
||||||
}
|
}
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class LutrisSourceIterable(SourceIterable):
|
|||||||
"game_id": self.source.game_id_format.format(
|
"game_id": self.source.game_id_format.format(
|
||||||
runner=row[3], game_id=row[0]
|
runner=row[3], game_id=row[0]
|
||||||
),
|
),
|
||||||
"executable": self.source.executable_format.format(game_id=row[0]),
|
"executable": self.source.make_executable(game_id=row[0]),
|
||||||
}
|
}
|
||||||
game = Game(values)
|
game = Game(values)
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class ExecutableFormatSource(Source):
|
|||||||
|
|
||||||
def make_executable(self, *args, **kwargs) -> str:
|
def make_executable(self, *args, **kwargs) -> str:
|
||||||
"""Use the executable format to"""
|
"""Use the executable format to"""
|
||||||
return self.executable_format.format(args, kwargs)
|
return self.executable_format.format(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class SteamSourceIterable(SourceIterable):
|
|||||||
"name": local_data["name"],
|
"name": local_data["name"],
|
||||||
"source": self.source.source_id,
|
"source": self.source.source_id,
|
||||||
"game_id": self.source.game_id_format.format(game_id=appid),
|
"game_id": self.source.game_id_format.format(game_id=appid),
|
||||||
"executable": self.source.executable_format.format(game_id=appid),
|
"executable": self.source.make_executable(game_id=appid),
|
||||||
}
|
}
|
||||||
game = Game(values)
|
game = Game(values)
|
||||||
|
|
||||||
|
|||||||
@@ -89,18 +89,24 @@ class SessionFileHandler(StreamHandler):
|
|||||||
|
|
||||||
# If uncompressed, compress
|
# If uncompressed, compress
|
||||||
if not path.name.endswith(".xz"):
|
if not path.name.endswith(".xz"):
|
||||||
|
try:
|
||||||
|
with open(path, "r", encoding="utf-8") as original_file:
|
||||||
|
original_data = original_file.read()
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
# If the file is corrupted, throw it away
|
||||||
|
path.unlink()
|
||||||
|
return
|
||||||
|
|
||||||
|
# Compress the file
|
||||||
compressed_path = path.with_suffix(path.suffix + ".xz")
|
compressed_path = path.with_suffix(path.suffix + ".xz")
|
||||||
with (
|
with lzma.open(
|
||||||
lzma.open(
|
compressed_path,
|
||||||
compressed_path,
|
"wt",
|
||||||
"wt",
|
format=FORMAT_XZ,
|
||||||
format=FORMAT_XZ,
|
preset=PRESET_DEFAULT,
|
||||||
preset=PRESET_DEFAULT,
|
encoding="utf-8",
|
||||||
encoding="utf-8",
|
) as lzma_file:
|
||||||
) as lzma_file,
|
lzma_file.write(original_data)
|
||||||
open(path, "r", encoding="utf-8") as original_file,
|
|
||||||
):
|
|
||||||
lzma_file.write(original_file.read())
|
|
||||||
path.unlink()
|
path.unlink()
|
||||||
path = compressed_path
|
path = compressed_path
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user