本文整理汇总了Python中lutris.thread.LutrisThread.set_stop_command方法的典型用法代码示例。如果您正苦于以下问题:Python LutrisThread.set_stop_command方法的具体用法?Python LutrisThread.set_stop_command怎么用?Python LutrisThread.set_stop_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lutris.thread.LutrisThread
的用法示例。
在下文中一共展示了LutrisThread.set_stop_command方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from lutris.thread import LutrisThread [as 别名]
# 或者: from lutris.thread.LutrisThread import set_stop_command [as 别名]
#.........这里部分代码省略.........
def play(self):
""" Launch the game. """
if not self.prelaunch():
return False
gameplay_info = self.runner.play()
logger.debug("Launching %s: %s" % (self.name, gameplay_info))
if isinstance(gameplay_info, dict):
if 'error' in gameplay_info:
show_error_message(gameplay_info)
return False
launch_arguments = gameplay_info['command']
else:
logger.error("Old method used for returning gameplay infos")
launch_arguments = gameplay_info
resolution = self.game_config.get_system('resolution')
if resolution:
desktop_control.change_resolution(resolution)
if self.game_config.get_system('reset_pulse'):
desktop_control.reset_pulse()
if self.game_config.get_system('hide_panels'):
self.desktop.hide_panels()
oss_wrapper = self.game_config.get_system("oss_wrapper")
if oss_wrapper:
launch_arguments.insert(0, audio.get_oss_wrapper(oss_wrapper))
ld_preload = gameplay_info.get('ld_preload')
if ld_preload:
launch_arguments.insert(0, 'LD_PRELOAD="{}"'.format(ld_preload))
ld_library_path = gameplay_info.get('ld_library_path')
if ld_library_path:
launch_arguments.insert(
0, 'LD_LIBRARY_PATH="{}"'.format(ld_library_path)
)
killswitch = self.game_config.get_system('killswitch')
self.heartbeat = GLib.timeout_add(5000, self.poke_process)
self.game_thread = LutrisThread(" ".join(launch_arguments),
path=self.runner.get_game_path(),
killswitch=killswitch)
if hasattr(self.runner, 'stop'):
self.game_thread.set_stop_command(self.runner.stop)
self.game_thread.start()
if 'joy2key' in gameplay_info:
self.joy2key(gameplay_info['joy2key'])
xboxdrv_config = self.game_config.get_system('xboxdrv')
if xboxdrv_config:
self.xboxdrv(xboxdrv_config)
def joy2key(self, config):
""" Run a joy2key thread. """
win = "grep %s" % config['window']
if 'notwindow' in config:
win = win + ' | grep -v %s' % config['notwindow']
wid = "xwininfo -root -tree | %s | awk '{print $1}'" % win
buttons = config['buttons']
axis = "Left Right Up Down"
rcfile = "~/.joy2keyrc"
command = "sleep 5 "
command += "&& joy2key $(%s) -X -rcfile %s -buttons %s -axis %s" % (
wid, rcfile, buttons, axis
)
joy2key_thread = LutrisThread(command)
self.game_thread.attach_thread(joy2key_thread)
joy2key_thread.start()
def xboxdrv(self, config):
command = ("pkexec xboxdrv --daemon --detach-kernel-driver "
"--dbus session --silent %s"
% config)
logger.debug("xboxdrv command: %s", command)
thread = LutrisThread(command)
thread.start()
def poke_process(self):
""" Watch game's process. """
if not self.game_thread.pid:
self.quit_game()
return False
return True
def quit_game(self):
""" Quit the game and cleanup. """
self.heartbeat = None
quit_time = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
logger.debug("game has quit at %s" % quit_time)
if self.game_config.get_system('resolution'):
desktop_control.reset_desktop()
if self.game_config.get_system('xboxdrv'):
logger.debug("Shutting down xboxdrv")
os.system("pkexec xboxdrvctl --shutdown")
if self.game_thread:
self.game_thread.stop()
示例2: Game
# 需要导入模块: from lutris.thread import LutrisThread [as 别名]
# 或者: from lutris.thread.LutrisThread import set_stop_command [as 别名]
#.........这里部分代码省略.........
dialogs.ErrorDialog("The selected terminal application "
"could not be launched:\n"
"%s" % terminal)
return False
# Env vars
env = {}
game_env = gameplay_info.get('env') or {}
env.update(game_env)
ld_preload = gameplay_info.get('ld_preload')
if ld_preload:
env["LD_PRELOAD"] = ld_preload
ld_library_path = []
if self.use_runtime(system_config):
env['STEAM_RUNTIME'] = os.path.join(settings.RUNTIME_DIR, 'steam')
ld_library_path += runtime.get_runtime_paths()
game_ld_libary_path = gameplay_info.get('ld_library_path')
if game_ld_libary_path:
ld_library_path.append(game_ld_libary_path)
if ld_library_path:
ld_full = ':'.join(ld_library_path)
env["LD_LIBRARY_PATH"] = "{}:$LD_LIBRARY_PATH".format(ld_full)
# /Env vars
self.game_thread = LutrisThread(launch_arguments,
runner=self.runner, env=env,
rootpid=gameplay_info.get('rootpid'),
term=terminal)
self.state = self.STATE_RUNNING
if hasattr(self.runner, 'stop'):
self.game_thread.set_stop_command(self.runner.stop)
self.game_thread.start()
if 'joy2key' in gameplay_info:
self.joy2key(gameplay_info['joy2key'])
xboxdrv_config = system_config.get('xboxdrv')
if xboxdrv_config:
self.xboxdrv_start(xboxdrv_config)
if self.runner.is_watchable:
# Create heartbeat every
self.heartbeat = GLib.timeout_add(HEARTBEAT_DELAY, self.beat)
def joy2key(self, config):
"""Run a joy2key thread."""
if not system.find_executable('joy2key'):
logger.error("joy2key is not installed")
return
win = "grep %s" % config['window']
if 'notwindow' in config:
win += ' | grep -v %s' % config['notwindow']
wid = "xwininfo -root -tree | %s | awk '{print $1}'" % win
buttons = config['buttons']
axis = "Left Right Up Down"
rcfile = os.path.expanduser("~/.joy2keyrc")
rc_option = '-rcfile %s' % rcfile if os.path.exists(rcfile) else ''
command = "sleep 5 "
command += "&& joy2key $(%s) -X %s -buttons %s -axis %s" % (
wid, rc_option, buttons, axis
)
joy2key_thread = LutrisThread(command)
self.game_thread.attach_thread(joy2key_thread)
joy2key_thread.start()
def xboxdrv_start(self, config):
示例3: Game
# 需要导入模块: from lutris.thread import LutrisThread [as 别名]
# 或者: from lutris.thread.LutrisThread import set_stop_command [as 别名]
#.........这里部分代码省略.........
prefix_command = system_config.get("prefix_command", '').strip()
if prefix_command and system.find_executable(prefix_command):
launch_arguments.insert(0, prefix_command)
ld_preload = gameplay_info.get('ld_preload')
if ld_preload:
launch_arguments.insert(0, 'LD_PRELOAD="{}"'.format(ld_preload))
ld_library_path = []
runtime64_path = os.path.join(settings.RUNTIME_DIR, "lib64")
if os.path.exists(runtime64_path):
ld_library_path.append(runtime64_path)
runtime32_path = os.path.join(settings.RUNTIME_DIR, "lib32")
if os.path.exists(runtime32_path):
ld_library_path.append(runtime32_path)
game_ld_libary_path = gameplay_info.get('ld_library_path')
if game_ld_libary_path:
ld_library_path.append(game_ld_libary_path)
if ld_library_path:
ld_full = ':'.join(ld_library_path)
ld_arg = 'LD_LIBRARY_PATH="{}:$LD_LIBRARY_PATH"'.format(ld_full)
launch_arguments.insert(0, ld_arg)
env = gameplay_info.get('env') or []
for var in env:
launch_arguments.insert(0, var)
killswitch = system_config.get('killswitch')
self.game_thread = LutrisThread(" ".join(launch_arguments),
path=self.runner.working_dir,
killswitch=killswitch)
if hasattr(self.runner, 'stop'):
self.game_thread.set_stop_command(self.runner.stop)
self.game_thread.start()
if 'joy2key' in gameplay_info:
self.joy2key(gameplay_info['joy2key'])
xboxdrv_config = system_config.get('xboxdrv')
if xboxdrv_config:
self.xboxdrv_start(xboxdrv_config)
if self.runner.is_watchable:
# Create heartbeat every
self.heartbeat = GLib.timeout_add(5000, self.poke_process)
def joy2key(self, config):
"""Run a joy2key thread."""
if not system.find_executable('joy2key'):
logger.error("joy2key is not installed")
return
win = "grep %s" % config['window']
if 'notwindow' in config:
win += ' | grep -v %s' % config['notwindow']
wid = "xwininfo -root -tree | %s | awk '{print $1}'" % win
buttons = config['buttons']
axis = "Left Right Up Down"
rcfile = os.path.expanduser("~/.joy2keyrc")
rc_option = '-rcfile %s' % rcfile if os.path.exists(rcfile) else ''
command = "sleep 5 "
command += "&& joy2key $(%s) -X %s -buttons %s -axis %s" % (
wid, rc_option, buttons, axis
)
joy2key_thread = LutrisThread(command)
self.game_thread.attach_thread(joy2key_thread)
joy2key_thread.start()
def xboxdrv_start(self, config):
示例4: Game
# 需要导入模块: from lutris.thread import LutrisThread [as 别名]
# 或者: from lutris.thread.LutrisThread import set_stop_command [as 别名]
#.........这里部分代码省略.........
self.state = self.STATE_STOPPED
return
# Env vars
game_env = gameplay_info.get('env') or {}
env.update(game_env)
system_env = system_config.get('env') or {}
env.update(system_env)
ld_preload = gameplay_info.get('ld_preload') or ''
env["LD_PRELOAD"] = ld_preload
# Runtime management
ld_library_path = ""
if self.runner.use_runtime():
runtime_env = runtime.get_env()
if 'STEAM_RUNTIME' in runtime_env and 'STEAM_RUNTIME' not in env:
env['STEAM_RUNTIME'] = runtime_env['STEAM_RUNTIME']
if 'LD_LIBRARY_PATH' in runtime_env:
ld_library_path = runtime_env['LD_LIBRARY_PATH']
game_ld_libary_path = gameplay_info.get('ld_library_path')
if game_ld_libary_path:
if not ld_library_path:
ld_library_path = '$LD_LIBRARY_PATH'
ld_library_path = ":".join(game_ld_libary_path, ld_library_path)
env["LD_LIBRARY_PATH"] = ld_library_path
# /Env vars
self.game_thread = LutrisThread(launch_arguments,
runner=self.runner, env=env,
rootpid=gameplay_info.get('rootpid'),
term=terminal)
if hasattr(self.runner, 'stop'):
self.game_thread.set_stop_command(self.runner.stop)
self.game_thread.start()
self.state = self.STATE_RUNNING
if 'joy2key' in gameplay_info:
self.joy2key(gameplay_info['joy2key'])
xboxdrv_config = system_config.get('xboxdrv')
if xboxdrv_config:
self.xboxdrv_start(xboxdrv_config)
self.heartbeat = GLib.timeout_add(HEARTBEAT_DELAY, self.beat)
def joy2key(self, config):
"""Run a joy2key thread."""
if not system.find_executable('joy2key'):
logger.error("joy2key is not installed")
return
win = "grep %s" % config['window']
if 'notwindow' in config:
win += ' | grep -v %s' % config['notwindow']
wid = "xwininfo -root -tree | %s | awk '{print $1}'" % win
buttons = config['buttons']
axis = "Left Right Up Down"
rcfile = os.path.expanduser("~/.joy2keyrc")
rc_option = '-rcfile %s' % rcfile if os.path.exists(rcfile) else ''
command = "sleep 5 "
command += "&& joy2key $(%s) -X %s -buttons %s -axis %s" % (
wid, rc_option, buttons, axis
)
joy2key_thread = LutrisThread(command)
self.game_thread.attach_thread(joy2key_thread)
joy2key_thread.start()
def xboxdrv_start(self, config):
command = [
示例5: Game
# 需要导入模块: from lutris.thread import LutrisThread [as 别名]
# 或者: from lutris.thread.LutrisThread import set_stop_command [as 别名]
#.........这里部分代码省略.........
# Env vars
game_env = gameplay_info.get('env') or {}
env.update(game_env)
ld_preload = gameplay_info.get('ld_preload')
if (ld_preload):
env["LD_PRELOAD"] = ld_preload
game_ld_libary_path = gameplay_info.get('ld_library_path')
if game_ld_libary_path:
ld_library_path = env.get("LD_LIBRARY_PATH")
if not ld_library_path:
ld_library_path = '$LD_LIBRARY_PATH'
ld_library_path = ":".join([game_ld_libary_path, ld_library_path])
env["LD_LIBRARY_PATH"] = ld_library_path
# /Env vars
include_processes = shlex.split(system_config.get('include_processes', ''))
exclude_processes = shlex.split(system_config.get('exclude_processes', ''))
monitoring_disabled = system_config.get('disable_monitoring')
process_watch = not monitoring_disabled
self.game_thread = LutrisThread(launch_arguments,
runner=self.runner,
env=env,
rootpid=gameplay_info.get('rootpid'),
watch=process_watch,
term=terminal,
log_buffer=self.log_buffer,
include_processes=include_processes,
exclude_processes=exclude_processes)
if hasattr(self.runner, 'stop'):
self.game_thread.set_stop_command(self.runner.stop)
self.game_thread.start()
self.state = self.STATE_RUNNING
# xboxdrv setup
xboxdrv_config = system_config.get('xboxdrv')
if xboxdrv_config:
self.xboxdrv_start(xboxdrv_config)
if monitoring_disabled:
logger.info("Process monitoring disabled")
else:
self.heartbeat = GLib.timeout_add(HEARTBEAT_DELAY, self.beat)
def xboxdrv_start(self, config):
command = [
"pkexec", "xboxdrv", "--daemon", "--detach-kernel-driver",
"--dbus", "session", "--silent"
] + config.split()
logger.debug("[xboxdrv] %s", ' '.join(command))
self.xboxdrv_thread = LutrisThread(command, include_processes=['xboxdrv'])
self.xboxdrv_thread.set_stop_command(self.xboxdrv_stop)
self.xboxdrv_thread.start()
def xboxdrv_stop(self):
os.system("pkexec xboxdrvctl --shutdown")
if os.path.exists("/usr/share/lutris/bin/resetxpad"):
os.system("pkexec /usr/share/lutris/bin/resetxpad")
def beat(self):
"""Watch the game's process(es)."""
if self.game_thread.error:
dialogs.ErrorDialog("<b>Error lauching the game:</b>\n" +