def run(args): locale.setlocale(locale.LC_ALL, "") # use system's default locale QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) data_dir = args.custom_network_storage if data_dir is None: from randovania.interface_common import persistence data_dir = persistence.local_data_dir() is_preview = args.preview start_logger(data_dir, is_preview) app = QtWidgets.QApplication(sys.argv) def main_done(done: asyncio.Task): e: typing.Optional[Exception] = done.exception() if e is not None: display_exception(e) app.exit(1) loop = create_loop(app) with loop: loop.create_task(qt_main(app, data_dir, args)).add_done_callback(main_done) loop.run_forever()
async def migrate_from_old_path(self, on_update): from randovania.interface_common import persistence files_to_commit = [] all_files = list(persistence.local_data_dir().joinpath("presets").glob("*.rdvpreset")) for i, old_file in enumerate(all_files): on_update(i, len(all_files)) preset = await VersionedPreset.from_file(old_file) try: preset.ensure_converted() path = self._file_name_for_preset(preset) preset.save_to_file(path) self.custom_presets[preset.uuid] = preset files_to_commit.append(path) except InvalidPreset as e: logging.info(f"Not migrating {preset.name}: {e}") continue on_update(len(all_files), len(all_files)) dulwich.porcelain.add(self._data_dir.parent, files_to_commit) author = "randovania <*****@*****.**>" dulwich.porcelain.commit(self._data_dir.parent, message=f"Migrated old presets using Randovania v{randovania.VERSION}", author=author, committer=author)
def should_do_migration(self): if not self.custom_presets: from randovania.interface_common import persistence for _ in persistence.local_data_dir().joinpath("presets").glob( "*.rdvpreset"): return True return False
def test_base_args( mock_get_data_path: MagicMock, mock_validate_game_files_path: MagicMock, ): # Setup mock_get_data_path.return_value = Path("data") game_root = Path("root") # Run results = claris_randomizer._base_args(game_root) # Assert expected_results = [ Path("data", "ClarisPrimeRandomizer", "Randomizer.exe"), Path("root"), "-data:" + str(persistence.local_data_dir().joinpath( "CustomEchoesRandomizerData.json")) ] assert results == expected_results mock_validate_game_files_path.assert_called_once_with(Path( "root", "files"))
def with_default_data_dir(cls) -> "Options": return cls(persistence.local_data_dir(), persistence.roaming_data_dir())
def _last_check_file() -> Path: return persistence.local_data_dir() / "last_releases.json"
def _get_custom_data_path() -> Path: from randovania.interface_common import persistence return persistence.local_data_dir().joinpath( "CustomEchoesRandomizerData.json")