Class: SimControl::PythonEnvironment
- Inherits:
-
BaseEnvironment
- Object
- BaseEnvironment
- SimControl::PythonEnvironment
- Defined in:
- lib/SimControl/environments/python.rb
Instance Method Summary collapse
- #execute(scenario) ⇒ Object
-
#initialize(script, args = {}) ⇒ PythonEnvironment
constructor
A new instance of PythonEnvironment.
- #interpreter ⇒ Object
Methods inherited from BaseEnvironment
Constructor Details
#initialize(script, args = {}) ⇒ PythonEnvironment
Returns a new instance of PythonEnvironment.
3 4 5 6 7 8 |
# File 'lib/SimControl/environments/python.rb', line 3 def initialize(script, args = {}) @script = script @interpreter = args.delete(:interpreter) @virtualenv = args.delete(:virtualenv) raise "passing a virtualenv requires an interpreter" if @virtualenv and not @interpreter end |
Instance Method Details
#execute(scenario) ⇒ Object
10 11 12 13 14 |
# File 'lib/SimControl/environments/python.rb', line 10 def execute(scenario) args = scenario.map { |k, v| "--#{ k } #{ v }" }.join " " command = [interpreter, @script, args].reject(&:nil?).reject(&:empty?).join " " `#{ command }` end |
#interpreter ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/SimControl/environments/python.rb', line 16 def interpreter if @virtualenv File.join(@virtualenv, "bin", @interpreter) else @interpreter end end |