本文整理汇总了Python中lutris.thread.LutrisThread类的典型用法代码示例。如果您正苦于以下问题:Python LutrisThread类的具体用法?Python LutrisThread怎么用?Python LutrisThread使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LutrisThread类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: xboxdrv
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()
示例2: execute
def execute(self, data):
"""Run an executable file"""
args = []
if isinstance(data, dict):
self._check_required_params('file', data, 'execute')
file_ref = data['file']
args_string = data.get('args', '')
for arg in shlex.split(args_string):
args.append(self._substitute(arg))
else:
file_ref = data
# Determine whether 'file' value is a file id or a path
exec_path = self._get_file(file_ref) or self._substitute(file_ref)
if not exec_path:
raise ScriptingError("Unable to find file %s" % file_ref,
file_ref)
if not os.path.exists(exec_path):
raise ScriptingError("Unable to find required executable",
exec_path)
self.chmodx(exec_path)
terminal = data.get('terminal')
if terminal:
terminal = system.get_default_terminal()
command = [exec_path] + args
logger.debug("Executing %s" % command)
thread = LutrisThread(command, env=get_runtime_env(), term=terminal)
thread.run()
示例3: execute
def execute(self, data):
"""Run an executable file."""
args = []
if isinstance(data, dict):
self._check_required_params("file", data, "execute")
file_ref = data["file"]
args_string = data.get("args", "")
for arg in shlex.split(args_string):
args.append(self._substitute(arg))
else:
file_ref = data
# Determine whether 'file' value is a file id or a path
exec_path = self._get_file(file_ref) or self._substitute(file_ref)
if not exec_path:
raise ScriptingError("Unable to find file %s" % file_ref, file_ref)
if not os.path.exists(exec_path):
raise ScriptingError("Unable to find required executable", exec_path)
self.chmodx(exec_path)
terminal = data.get("terminal")
if terminal:
terminal = system.get_default_terminal()
command = [exec_path] + args
logger.debug("Executing %s" % command)
thread = LutrisThread(command, env=runtime.get_env(), term=terminal, cwd=self.target_path)
self.abort_current_task = thread.killall
thread.run()
self.abort_current_task = None
示例4: remove_game_data
def remove_game_data(self, **kwargs):
if not self.is_installed():
installed = self.install_dialog()
if not installed:
return False
appid = self.game_config.get('appid')
logger.debug("Launching Wine Steam uninstall of game %s" % appid)
command = '"%s" steam://uninstall/%s' % (self.steam_exe, appid)
thread = LutrisThread(command, path=self.working_dir)
thread.start()
示例5: remove_game_data
def remove_game_data(self, **kwargs):
if not self.is_installed():
installed = self.install_dialog()
if not installed:
return False
appid = self.game_config.get("appid")
logger.debug("Launching Wine Steam uninstall of game %s" % appid)
command = [self.steam_exe, "steam://uninstall/%s" % appid]
thread = LutrisThread(command, runner=self)
thread.start()
示例6: remove_game_data
def remove_game_data(self, appid=None, **kwargs):
if not self.is_installed():
installed = self.install_dialog()
if not installed:
return False
appid = appid if appid else self.appid
env = self.get_env(full=False)
command = self.launch_args + ['steam://uninstall/%s' % appid]
self.prelaunch()
thread = LutrisThread(command, runner=self, env=env, watch=False)
thread.start()
示例7: remove_game_data
def remove_game_data(self, **kwargs):
if not self.is_installed():
installed = self.install_dialog()
if not installed:
return False
appid = self.game_config.get('appid')
env = self.get_env()
command = self.launch_args + ['steam://uninstall/%s' % appid]
self.prepare_launch()
thread = LutrisThread(' '.join(command), runner=self, env=env)
thread.start()
示例8: remove_game_data
def remove_game_data(self, appid=None, **kwargs):
if not self.is_installed():
installed = self.install_dialog()
if not installed:
return False
appid = appid if appid else self.game_config.get('appid')
if appid is None:
raise RuntimeError('No appid given for uninstallation '
'(game config=%s)' % self.game_config)
logger.debug("Launching Steam uninstall of game %s" % appid)
command = [self.get_executable(), 'steam://uninstall/%s' % appid]
thread = LutrisThread(command, runner=self)
thread.start()
示例9: run
def run(self, *args):
"""Run the runner alone."""
if not self.runnable_alone:
return
if not self.is_installed():
installed = self.install_dialog()
if not installed:
return
command_data = self.get_run_data()
command = command_data.get('command')
env = (command_data.get('env') or {}).copy()
thread = LutrisThread(command, runner=self, env=env, watch=False)
thread.start()
示例10: joy2key
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()
示例11: wineexec
def wineexec(executable, args="", wine_path=None, prefix=None, arch=None,
working_dir=None, winetricks_wine='', blocking=False):
"""Execute a Wine command."""
detected_arch = detect_prefix_arch(prefix)
executable = str(executable) if executable else ''
if arch not in ('win32', 'win64'):
arch = detected_arch or 'win32'
if not wine_path:
wine_path = wine().get_executable()
if not working_dir:
if os.path.isfile(executable):
working_dir = os.path.dirname(executable)
if executable.endswith(".msi"):
executable = 'msiexec /i "%s"' % executable
elif executable:
executable = '%s' % executable
# Create prefix if necessary
if not detected_arch:
wine_bin = winetricks_wine if winetricks_wine else wine_path
create_prefix(prefix, wine_path=wine_bin, arch=arch)
env = {
'WINEARCH': arch
}
if winetricks_wine:
env['WINE'] = winetricks_wine
else:
env['WINE'] = wine_path
if prefix:
env['WINEPREFIX'] = prefix
wine_config = LutrisConfig(runner_slug='wine')
if not wine_config.system_config['disable_runtime'] and not runtime.is_disabled():
env['LD_LIBRARY_PATH'] = ':'.join(runtime.get_paths())
command = [wine_path]
if executable:
command.append(executable)
command += shlex.split(args)
if blocking:
return system.execute(command, env=env, cwd=working_dir)
else:
thread = LutrisThread(command, runner=wine(), env=env, cwd=working_dir)
thread.start()
return thread
示例12: play
def play(self):
"""Launch the game."""
if not self.runner:
dialogs.ErrorDialog("Invalid game configuration: Missing runner")
return False
if not self.prelaunch():
return False
system_config = self.runner.system_config
self.original_outputs = display.get_outputs()
gameplay_info = self.runner.play()
logger.debug("Launching %s: %s" % (self.name, gameplay_info))
if 'error' in gameplay_info:
show_error_message(gameplay_info)
return False
launch_arguments = gameplay_info['command']
restrict_to_display = system_config.get('display')
if restrict_to_display:
display.turn_off_except(restrict_to_display)
self.resolution_changed = True
resolution = system_config.get('resolution')
if resolution:
display.change_resolution(resolution)
self.resolution_changed = True
if system_config.get('reset_pulse'):
audio.reset_pulse()
oss_wrapper = system_config.get("oss_wrapper")
if audio.get_oss_wrapper(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 = 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(xboxdrv_config)
if self.runner.is_watchable:
# Create heartbeat every
self.heartbeat = GLib.timeout_add(5000, self.poke_process)
示例13: play
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
restrict_to_display = self.game_config.get_system('display')
if restrict_to_display:
display.turn_off_except(restrict_to_display)
self.resolution_changed = True
resolution = self.game_config.get_system('resolution')
if resolution:
display.change_resolution(resolution)
self.resolution_changed = True
if self.game_config.get_system('reset_pulse'):
audio.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)
示例14: xboxdrv_start
def xboxdrv_start(self, config):
command = [
"pkexec", "xboxdrv", "--daemon", "--detach-kernel-driver",
"--dbus", "session", "--silent"
] + config.split()
logger.debug("xboxdrv command: %s", command)
self.xboxdrv_thread = LutrisThread(command)
self.xboxdrv_thread.set_stop_command(self.xboxdrv_stop)
self.xboxdrv_thread.start()
示例15: xboxdrv_start
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()