diff --git a/lutris/gui/installerconfigvbox.py b/lutris/gui/installerconfigvbox.py index 93728790c..7c7e1ba1c 100644 --- a/lutris/gui/installerconfigvbox.py +++ b/lutris/gui/installerconfigvbox.py @@ -20,24 +20,24 @@ ############################################################################### import gtk - -import lutris.runners - +from lutris.runners import import_runner from lutris.gui.configvbox import ConfigVBox class InstallerConfigVBox(ConfigVBox): + """This file is going to disapear anytime now.""" def __init__(self,lutris_config,caller): ConfigVBox.__init__(self,"game",caller) self.lutris_config = lutris_config self.lutris_config.config_type = "game" - self.runner_class = self.lutris_config.runner - runner = eval("lutris.runners."+self.runner_class+"."+self.runner_class+"()") + self.runner_classname = self.lutris_config.runner + runner_cls = import_runner(self.runner_classname) + runner = runner_cls() if hasattr(runner,"installer_options"): self.options = runner.installer_options else: no_option_label = gtk.Label("No game options") self.pack_start(no_option_label) - return + return self.generate_widgets() diff --git a/lutris/gui/runnerconfigvbox.py b/lutris/gui/runnerconfigvbox.py index 314d78264..4cb83a5b6 100644 --- a/lutris/gui/runnerconfigvbox.py +++ b/lutris/gui/runnerconfigvbox.py @@ -20,8 +20,7 @@ ############################################################################### import gtk - -import lutris.runners +from lutris.runners import import_runner from lutris.gui.configvbox import ConfigVBox class RunnerConfigVBox(ConfigVBox): @@ -30,14 +29,12 @@ class RunnerConfigVBox(ConfigVBox): runner configuration. """ def __init__(self, lutris_config, caller): - runner = lutris_config.runner - ConfigVBox.__init__(self, runner, caller) - - # FIXME ugly - runner_instance = eval("lutris.runners."+runner+"."+runner+"()") - - if hasattr(runner_instance, "runner_options"): - self.options = runner_instance.runner_options + runner_classname = lutris_config.runner + ConfigVBox.__init__(self, runner_classname, caller) + runner_class = import_runner(runner_classname) + runner = runer_class() + if hasattr(runner, "runner_options"): + self.options = runner.runner_options self.lutris_config = lutris_config self.generate_widgets() else: diff --git a/lutris/gui/runnersdialog.py b/lutris/gui/runnersdialog.py index 803542e65..5e8c37ad0 100644 --- a/lutris/gui/runnersdialog.py +++ b/lutris/gui/runnersdialog.py @@ -21,8 +21,7 @@ import gtk -import lutris.runners - +from lutris.runners import import_runner from lutris.config import LutrisConfig from lutris.gui.runnerconfigvbox import RunnerConfigVBox from lutris.gui.systemconfigvbox import SystemConfigVBox @@ -91,11 +90,8 @@ class RunnersDialog(gtk.Dialog): for runner in runner_list: hbox = gtk.HBox() #Label - runner_module = __import__('lutris.runners.%s' % runner, - globals(), locals(), [runner], -1) - runner_cls = getattr(runner_module, runner) - runner_instance = runner_cls() - #runner_instance = eval("lutris.runners." + runner + "." + runner + "()") + runner_class = import_runner(runner) + runner_instance = runner_class() machine = runner_instance.machine runner_label = gtk.Label() runner_label.set_markup(""+runner + " ( " + machine + " ) ") @@ -125,11 +121,12 @@ class RunnersDialog(gtk.Dialog): def close(self, widget=None, other=None): self.destroy() - def on_install_clicked(self,widget,runner): + def on_install_clicked(self,widget,runner_classname): """Install a runner""" #FIXME : this is ugly ! - runner_instance = eval("lutris.runners." + runner + "." + runner + "()") - runner_instance.install() + runner_class = import_runner(runner_classname) + runner = runner_classname() + runner.install() def on_configure_clicked(self,widget,runner): RunnerConfigDialog(runner)