python/steamutil,steamsync: Add windows support

master
Taeyeon Mori 5 years ago
parent 71f3810b0e
commit 8edb723f09
  1. 5
      bin/sync_savegames
  2. 10
      lib/python/steamsync.py
  3. 32
      lib/python/steamutil.py

@ -19,8 +19,9 @@ sync = SteamSync(Path("~/Nextcloud/Misc/Savegames").expanduser())
@sync.by_name("zanzarah")
def zanzarah(op):
with op.game_directory.prefix("Save") as set:
set += "*"
set.execute()
set += "*.dat"
if set.show_confirm():
set.execute()
#@sync.by_id(787860)
def fs19(op):

@ -10,7 +10,7 @@ import shutil
from pathlib import Path
from typing import Tuple, Dict, List, Union, Set, Callable, Any
from steamutil import Steam, App, CachedProperty
from steamutil import Steam, App, CachedProperty, MalformedManifestError
class AppNotFoundType:
@ -137,9 +137,11 @@ class SyncSet:
print(" Target is newer: ", ", ".join(map(str, self.files_from_target)))
print(" Unmodified: ", ", ".join(map(str, self.files_unmodified)))
print("Press enter to continue")
input()
return True # TODO: Proper thingey
print("Continue? <Y/n> ", end="")
resp = input().strip()
if resp.lower() in ("y", "yes", ""):
return True
return False
def execute(self, *, make_inconsistent=False) -> bool:
operations = []

@ -77,6 +77,12 @@ class DictPathProperty(DictPathRoProperty):
_vdf = VdfParser()
class MalformedManifestError(Exception):
@property
def filename(self):
return self.args[1]
class App:
steam: 'Steam'
library_folder: 'LibraryFolder'
@ -96,6 +102,9 @@ class App:
else:
self.manifest = manifest_data
if "AppState" not in self.manifest:
raise MalformedManifestError("App manifest doesn't have AppState key", self.manifest_path)
def __repr__(self):
return "<steamutil.App %d '%s' @ \"%s\">" % (self.appid, self.name, self.install_path)
@ -185,7 +194,11 @@ class LibraryFolder:
@property
def apps(self) -> Iterable[App]:
return (App(self, mf) for mf in self.appmanifests)
for mf in self.appmanifests:
try:
yield App(self, mf)
except MalformedManifestError as e:
print("Warning: Malformed app manifest:", e.filename)
def get_app(self, appid: int) -> Optional[App]:
manifest = self.steamapps_path / ("appmanifest_%d.acf" % appid)
@ -309,6 +322,23 @@ class Steam:
steamroot = path / name
if steamroot.exists():
return steamroot
elif sys.platform.startswith("win"):
try:
import winreg
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "SOFTWARE\\Valve\\Steam")
path, t = winreg.QueryValueEx(key, "steampath")
if (t == winreg.REG_SZ):
return Path(path)
except WindowsError:
pass
# try PROGRAMFILES
pfiles = (os.environ.get("ProgramFiles(x86)", "C:\Program Files (x86)"),
os.environ.get("ProgramFiles", "C:\Program Files"))
for path in pfiles:
if path.exists():
path /= "Steam"
if path.exists():
return path
# Various paths
@property

Loading…
Cancel
Save