def _load_profile_names(self):
"""
Loads names for profiles ids in q_profiles.
This is same as _load_game_names, but for profiles.
"""
content_path = os.path.join(self._find_steamapps(), "workshop/content")
if not os.path.exists(content_path):
log.warning("Cannot find '%s'; Cannot import anything without it", content_path)
return
while True:
self._s_profiles.acquire(True) # Wait until something is added to the queue
try:
index, gameid, profile_id = self._q_profiles.popleft()
except IndexError:
break
self._lock.acquire()
for user in os.listdir(content_path):
filename = os.path.join(content_path, user, profile_id, "controller_configuration.vdf")
if not os.path.exists(filename):
# If there is no 'controller_configuration.vdf', try finding *_legacy.bin
filename = self._find_legacy_bin(os.path.join(content_path, user, profile_id))
if not filename or not os.path.exists(filename):
# If not even *_legacy.bin is found, skip to next user
continue
log.info("Reading '%s'", filename)
try:
data = parse_vdf(open(filename, "r"))
name = data['controller_mappings']['title']
GLib.idle_add(self._set_profile_name, index, name, filename)
break
except Exception, e:
log.error("Failed to read profile name from '%s'", filename)
log.exception(e)
else:
log.warning("Profile %s for game %s not found.", profile_id, gameid)
name = _("(not found)")
GLib.idle_add(self._set_profile_name, index, name, None)
self._lock.release()
评论列表
文章目录