def install_game(self, appid, generate_acf=False): logger.debug("Installing steam game %s", appid) if generate_acf: acf_data = get_default_acf(appid, appid) acf_content = to_vdf(acf_data) steamapps_path = self.get_default_steamapps_path() if not steamapps_path: raise RuntimeError("Could not find Steam path, is Steam installed?") acf_path = os.path.join(steamapps_path, "appmanifest_%s.acf" % appid) with open(acf_path, "w") as acf_file: acf_file.write(acf_content) if is_running(): shutdown() time.sleep(5) command = [self.get_executable(), "steam://install/%s" % appid] subprocess.Popen(command)
def test_dict_to_vdf(self): appstate = OrderedDict() userconfig = OrderedDict() userconfig["gameid"] = "13240" userconfig["name"] = "Unreal Tournament" appstate["UserConfig"] = userconfig appstate["StateFlags"] = "4" appstate["appID"] = "13240" dict_data = OrderedDict() dict_data["AppState"] = appstate expected_vdf = """"AppState" { \t"UserConfig" \t{ \t\t"gameid"\t\t"13240" \t\t"name"\t\t"Unreal Tournament" \t} \t"StateFlags"\t\t"4" \t"appID"\t\t"13240" }""" vdf_data = vdf.to_vdf(dict_data) self.assertEqual(vdf_data.strip(), expected_vdf.strip())
def test_dict_to_vdf(self): appstate = OrderedDict() userconfig = OrderedDict() userconfig['gameid'] = "13240" userconfig['name'] = "Unreal Tournament" appstate['UserConfig'] = userconfig appstate['StateFlags'] = '4' appstate['appID'] = '13240' dict_data = OrderedDict() dict_data['AppState'] = appstate expected_vdf = """"AppState" { \t"UserConfig" \t{ \t\t"gameid"\t\t"13240" \t\t"name"\t\t"Unreal Tournament" \t} \t"StateFlags"\t\t"4" \t"appID"\t\t"13240" }""" vdf_data = vdf.to_vdf(dict_data) self.assertEqual(vdf_data.strip(), expected_vdf.strip())