Skip to content

Instantly share code, notes, and snippets.

@jikanter
Last active December 26, 2024 20:25
Show Gist options
  • Select an option

  • Save jikanter/4764cfc3e4c6edd9812eee893126703a to your computer and use it in GitHub Desktop.

Select an option

Save jikanter/4764cfc3e4c6edd9812eee893126703a to your computer and use it in GitHub Desktop.
[Execute Python From Lua] #lua
function runPythonCode(scriptCode)
--local output, status, type, rc = hs.execute("PATH=/usr/local/bin:${PATH}; python -c 'import sys; sys.stdout.write(str(123))'")
local output, status, type, rc = hs.execute("PATH=/usr/local/bin:${PATH}; python -c '" .. scriptCode .. "'")
local response = {
output = output,
status = status,
type = type,
rc = rc
}
return response
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment