python

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const PluginName = "python"

Variables

View Source
var Handler = func() *chi.Mux {
	mux := chi.NewMux()
	mux.NotFound(rest.NotFoundHandler)
	mux.MethodNotAllowed(rest.NotFoundHandler)
	mux.Post("/runtypes/python", StartPythonProcess)
	mux.Delete("/runtypes/python/{apikey}", StopPython)
	return mux
}()

Handler is the main API handler

View Source
var PathNames = []string{"python", "python3", "pypy3"}

Paths to search for the executable. These are commonly used names when python is in PATH

Functions

func EnsureVenv

func EnsureVenv(pypath, folder string) (string, error)

EnsureVenv makes sure that a venv exists in the given folder. If not, it creates one there. Returns the path of the venv's python executable.

func KillPython

func KillPython(w http.ResponseWriter, r *http.Request)

func RunCommand

func RunCommand(pypath string, args []string) error

func RunPython

func RunPython(w http.ResponseWriter, r *http.Request)

func SearchPython

func SearchPython() (string, error)

SearchPython finds a valid installed python version

func Start

func Start(db *database.AdminDB, i *run.Info, h run.BuiltinHelper) error

Start checks the currently set python path to make sure that it is valid

func StartPythonProcess

func StartPythonProcess(w http.ResponseWriter, r *http.Request)

func StopPython

func StopPython(w http.ResponseWriter, r *http.Request)

func TestPython

func TestPython(exepath string) error

TestPython checks if the given python version satisfies all requirements

Types

type PythonCandidate

type PythonCandidate struct {
	Path    string
	PipArgs []string
}

type PythonSettings

type PythonSettings struct {
	sync.Mutex                     // Defends Cmd
	Cmd        map[string]*run.Cmd `mapstructure:"-"`

	IsEnabled bool              `mapstructure:"-"`
	DB        *database.AdminDB `mapstructure:"-"`

	Path          string   `mapstructure:"path"`
	PipArgs       []string `mapstructure:"pip_args"`
	VenvArgs      []string `mapstructure:"venv_args"`
	PerPluginVenv bool     `mapstructure:"per_plugin_venv"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL