Module: Wavesync::PythonVenv

Defined in:
lib/wavesync/python_venv.rb

Constant Summary collapse

PYTHON_PATH =
File.expand_path('~/.wavesync-venv/bin/python3').freeze

Class Method Summary collapse

Class Method Details

.available?Boolean

: () -> bool

Returns:

  • (Boolean)


11
12
13
# File 'lib/wavesync/python_venv.rb', line 11

def self.available?
  File.executable?(PYTHON_PATH)
end

.essentia_available?Boolean

: () -> bool?

Returns:

  • (Boolean)


16
17
18
# File 'lib/wavesync/python_venv.rb', line 16

def self.essentia_available?
  available? && system("#{PYTHON_PATH} -c 'import essentia' > /dev/null 2>&1")
end

.run_script(script, file_path) ⇒ Object

: (String script, String file_path) -> String



21
22
23
# File 'lib/wavesync/python_venv.rb', line 21

def self.run_script(script, file_path)
  `#{PYTHON_PATH} -c #{Shellwords.escape(script)} #{Shellwords.escape(file_path)} 2>/dev/null`
end