示例#1
0
def steam_is_running():
  check_function = pf.platform_specific(windows=windows_steam_is_running, osx=osx_steam_is_running, linux=linux_steam_is_running)
  try:
    return check_function()
  except:
    ice_logger.log_warning('Could not determine if Steam is running. Make sure Steam is closed before running Ice.')
    return False
示例#2
0
def steam_is_running():
    check_function = pf.platform_specific(windows=windows_steam_is_running,
                                          osx=osx_steam_is_running,
                                          linux=linux_steam_is_running)
    try:
        return check_function()
    except:
        ice_logger.log_warning(
            'Could not determine if Steam is running. Make sure Steam is closed before running Ice.'
        )
        return False
shortcuts.vdf file, which is obviously useful for Ice
"""

import os

import platform_helper as pf

# Used to find the shortcuts.vdf file
osx_userdata_directory = "~/Library/Application Support/Steam/userdata/"
linux_userdata_directory = "~/.local/share/Steam/userdata/"

def windows_steam_location():
    import _winreg as registry
    key = registry.CreateKey(registry.HKEY_CURRENT_USER,"Software\Valve\Steam")
    return registry.QueryValueEx(key,"SteamPath")[0]

def windows_userdata_location():
    # On Windows, the userdata directory is the steam installation directory
    # with 'userdata' appeneded
    return os.path.join(windows_steam_location(),"userdata")

def osx_userdata_location():
    # I'm pretty sure the user can't change this on OS X. I think it always
    # goes to the same location
    return os.path.expanduser(osx_userdata_directory)

def linux_userdata_location():
    return os.path.expanduser(linux_userdata_directory)

steam_userdata_location = pf.platform_specific(windows=windows_userdata_location, osx=osx_userdata_location, linux=linux_userdata_location)
示例#4
0
#!/usr/bin/env python
# encoding: utf-8
"""
process_helper.py

Created by Scott on 2013-06-03.
Copyright (c) 2013 Scott Rice. All rights reserved.
"""

import subprocess

import platform_helper as pf

def windows_steam_is_running():
    """(Windows) Checks if Steam is currently running. Adapted from:
    http://timgolden.me.uk/python/wmi/cookbook.html"""
    return "Steam.exe" in subprocess.check_output("tasklist", shell=True)

def osx_steam_is_running():
    """(OS X) Checks if Steam is currently running."""
    return "Steam.app" in subprocess.check_output("ps -A", shell=True)

def linux_steam_is_running():
    """(Linux) Checks if Steam is currently running."""
    return "steam" in subprocess.check_output("ps -A", shell=True)

steam_is_running = pf.platform_specific(windows=windows_steam_is_running, osx=osx_steam_is_running, linux=linux_steam_is_running)
def osx_userdata_location():
    # I'm pretty sure the user can't change this on OS X. I think it always
    # goes to the same location
    if config_userdata_location() == "":
        out = os.path.expanduser(osx_userdata_directory)
    else:
        out = config_userdata_location()
    if not os.path.exists(out):
        raise IOError(
            "Steam userdata directory not found in location:\n" + out +
            "\nPlease configure Steam's userdata directory in config.txt")
    return out


def linux_userdata_location():
    if config_userdata_location() == "":
        out = os.path.expanduser(linux_userdata_directory)
    else:
        out = config_userdata_location()
    if not os.path.exists(out):
        raise IOError(
            "Steam userdata directory not found in location:\n" + out +
            "\nPlease configure Steam's userdata directory in config.txt")
    return out


steam_userdata_location = pf.platform_specific(
    windows=windows_userdata_location,
    osx=osx_userdata_location,
    linux=linux_userdata_location)