def check_steam_dir(): if get_config('steam_path') == 'reg' and os.path.isfile( fetch_reg('SteamPath') + '\\Steam.exe'): return True elif os.path.isfile(get_config('steam_path') + '\\Steam.exe'): return True else: return False
def open_screenshot(steamid64, steam_path=get_config('steam_path')): if steam_path == 'reg': steam_path = fetch_reg('steampath') if '/' in steam_path: steam_path = steam_path.replace('/', '\\') os.startfile( f'{steam_path}\\userdata\\{steam64_to_32(steamid64)}\\760\\remote')
def test(): print('Listing current config...') print('locale:', get_config('locale')) print('autoexit:', get_config('autoexit')) print('mode:', get_config('mode')) print('try_soft_shutdown:', get_config('try_soft_shutdown')) print('show_avatar:', get_config('show_avatar')) print('steam_path:', get_config('steam_path')) print('Checking registry...') for key in ('AutoLoginUser', 'RememberPassword', 'SteamExe', 'SteamPath', 'pid', 'ActiveUser'): print(f'{key}:', fetch_reg(key)) print('Checking Steam.exe location...') if check_steam_dir() and get_config('steam_path') == 'reg': print('Steam located at', fetch_reg('steampath')) elif check_steam_dir(): print('Steam located at', get_config('steam_path'), '(Manually set)') else: print('Steam directory invalid') return False return True
def steam_running(): """Check if Steam is running""" steam_pid = fetch_reg('pid') if steam_pid == 0: return False try: process = psutil.Process(pid=steam_pid) name = process.name() if name.lower() == 'steam.exe': return True else: return False except psutil.NoSuchProcess: return False
def loginusers(): ''' Fetch loginusers.vdf and return SteamID64, AccountName, PersonaName values as lists. :param steam_path: Steam installation path override ''' if get_config('steam_path') == 'reg': steam_path = fetch_reg('steampath') else: steam_path = get_config('steam_path') if '/' in steam_path: steam_path = steam_path.replace('/', '\\') vdf_file = os.path.join(steam_path, 'config', 'loginusers.vdf') try: with open(vdf_file, 'r', encoding='utf-8') as vdf_file: vdf = vdf_file.read().splitlines() except FileNotFoundError: return [], [], [] steam64_list = [] account_name = [] persona_name = [] rep = {"\t": "", '"': ""} rep = dict((re.escape(k), v) for k, v in rep.items()) pattern = re.compile("|".join(rep.keys())) for i, v in enumerate(vdf): if v == "\t{": steam64 = pattern.sub(lambda m: rep[re.escape(m.group(0))], vdf[i - 1]) account = pattern.sub(lambda m: rep[re.escape(m.group(0))], vdf[i + 1]) persona = pattern.sub(lambda m: rep[re.escape(m.group(0))], vdf[i + 2]) steam64_list.append(steam64) account_name.append(account.replace("AccountName", "")) persona_name.append(persona.replace("PersonaName", "")) return steam64_list, account_name, persona_name