mobilizon.chapril.org-mobil.../lib/service/python_port.ex
Thomas Citharel 0c667b13ae
Export participants to different formats
* CSV
* PDF (requires Python dependency `weasyprint`)
* ODS (requires Python dependency `pyexcel_ods3`)

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2021-10-05 10:52:55 +02:00

29 lines
621 B
Elixir

defmodule Mobilizon.PythonPort do
@moduledoc """
Port to use Python modules from Elixir
"""
use Export.Python
@doc """
## Parameters
- path: directory to include in python path
"""
@spec python_instance(String.t()) :: pid
def python_instance(path) do
python = "/usr/bin/python3"
{:ok, pid} = Python.start(python: python, python_path: path)
pid
end
@doc """
Call python function using MFA format
"""
@spec call_python(pid, binary, binary, list) :: any
def call_python(pid, module, function, arguments \\ []) do
Python.call(pid, module, function, arguments)
end
end