def get_app_info(self, app_id): self.try_delete_cache() output = self._get_steam_output('login anonymous', 'app_info_update 1', 'app_info_print %s' % app_id, 'app_info_print %s' % app_id, 'quit').splitlines() first_index = None last_index = None for index, line in enumerate(output): if 'AppID : %s' % app_id in line: if first_index is None: first_index = index continue else: last_index = index break if first_index is None or last_index is None: raise Exception('couldnt parse steamcmd app_info output') acf_output = output[first_index + 1:last_index] return acf.loads('\n'.join(acf_output))
def CreateGameSaveClass(path): # some game's info have spacial word like 'Sekiro™','古剑奇谭三(Gujian3)' with open(path, encoding="utf-8") as f: line = f.read() data = acf.loads(line) return GameInfo(data['AppState']['appid'], data['AppState']['name'], data['AppState']['installdir'])
def _check_steam_for_update(self, app_id: str, branch: str): manifest_file = get_server_path( ["steamapps", f"appmanifest_{app_id}.acf"]) if not os.path.isfile(manifest_file): self.logger.debug("No local manifet") return True manifest = None with open(manifest_file, "r") as f: manifest = acf.load(f) stdout = self.run_command( (f"{self.config.steamcmd_path} +app_info_update 1 " f"+app_info_print {app_id} +quit"), redirect_output=True, ) index = stdout.find(f'"{app_id}"') app_info = acf.loads(stdout[index:]) try: current_buildid = app_info[app_id]["depots"]["branches"][branch][ "buildid"] except KeyError: self.logger.debug("Failed to parse remote manifest") return True self.logger.debug(f"current: {manifest['AppState']['buildid']}") self.logger.debug(f"latest: {current_buildid}") return manifest["AppState"]["buildid"] != current_buildid
def test_loads_wrong_type(): with pytest.raises(TypeError): acf.loads(b'\x00\x01\x02')
def test_loads_dumps_with_wrapper(acf_data): loaded = acf.loads(acf_data, wrapper=OrderedDict) assert isinstance(loaded, OrderedDict) assert acf.dumps(loaded) == acf_data
def test_loads_dumps(acf_data): loaded = acf.loads(acf_data) assert acf.dumps(sort_dict(loaded)) == acf_data
def test_acf_keys_exist(acf_data): data = acf.loads(acf_data) assert 'BytesDownloaded' in data['AppState']['DlcDownloads']['202988'] assert 'BytesToDownload' in data['AppState']['DlcDownloads']['202988']
def test_loads_dumps(acf_data): assert acf.dumps(acf.loads(acf_data)) == acf_data